3.4.2-stable review
Subsystems (51)
Greg KH
maintainerPATCH 1/82 exofs: Fix CRASH on very early IO errors.
In reply to Greg KH3.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Boaz Harrosh <[email protected]>
commit 6abe4a87f7bc7978705c386dbba0ca0c7790b3ec upstream.
If at exofs_fill_super() we had an early termination do to any error, like an IO error while reading the super-block. We would crash inside exofs_free_sbi().
This is because sbi->oc.numdevs was set to 1, before we actually have a device table at all.
Fix it by moving the sbi->oc.numdevs = 1 to after the allocation of the device table.
--- fs/exofs/super.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/exofs/super.c +1 -1
@@ -745,7 +745,6 @@ static int exofs_fill_super(struct super sbi->one_comp.obj.partition = opts->pid; sbi->one_comp.obj.id =0 ;exofs_make_credential (sbi->one_comp.cred, &sbi->one_comp.obj); - sbi->oc.numdevs =1 ; sbi->oc.single_comp =EC_SINGLE_COMP ; sbi->oc.comps = &sbi->one_comp;
@@ -804,6 +803,7 @@ static int exofs_fill_super(struct super goto free_sbi;ore_comp_set_dev (&sbi->oc,0 , od); + sbi->oc.numdevs =1 ; }__sbi_read_stats (sbi);
Greg KH
maintainerPATCH 2/82 microblaze: Do not select GENERIC_GPIO by default
In reply to Greg KH3.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lars-Peter Clausen <[email protected]>
commit 59516b07b4ffa7e607a5787674ea3c405f1b390c upstream.
The microblaze architecture does not provide a native GPIO API implementation nor requires GPIOLIB, but still selects GENERIC_GPIO by default. As a result the following build error occurs, if GPIOLIB is not selected:
include/asm-generic/gpio.h: In function 'gpio_get_value_cansleep':
include/asm-generic/gpio.h:218: error: implicit declaration of function '__gpio_get_value' include/asm-generic/gpio.h: In function 'gpio_set_value_cansleep':
include/asm-generic/gpio.h:224: error: implicit declaration of function '__gpio_set_value'
This patch addresses the issue by not selecting GENERIC_GPIO by default. This causes the GPIO API to be stubbed out if no implementation is provided.
--- arch/microblaze/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/microblaze/Kconfig +1 -1
@@ -57,7 +57,7 @@ config GENERIC_CLOCKEVENTS def_bool y config GENERIC_GPIO - def_bool y + bool config GENERIC_CSUM def_bool y
Greg KH
maintainerPATCH 3/82 SCSI: fix scsi_wait_scan
In reply to Greg KH3.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: James Bottomley <[email protected]>
commit 1ff2f40305772b159a91c19590ee159d3a504afc upstream.
Commit c751085943362143f84346d274e0011419c84202
Author: Rafael J. Wysocki <[email protected]> Date: Sun Apr 12 20:06:56 2009 +0200
PM/Hibernate: Wait for SCSI devices scan to complete during resume
Broke the scsi_wait_scan module in 2.6.30. Apparently debian still uses it so fix it and backport to stable before removing it in 3.6.
The breakage is caused because the function template in include/scsi/scsi_scan.h is defined to be a nop unless SCSI is built in. That means that in the modular case (which is every distro), the scsi_wait_scan module does a simple async_synchronize_full() instead of waiting for scans.
--- drivers/scsi/scsi_wait_scan.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/scsi_wait_scan.c +1 -1
@@ -12,7 +12,7 @@#include <linux/module.h> #include <linux/device.h> -#include <scsi/scsi_scan.h> +#include "scsi_priv.h" static int __init wait_scan_init (void ) {
Greg KH
maintainerPATCH 4/82 SCSI: Fix dm-multipath starvation when scsi host is busy
In reply to Greg KH3.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jun'ichi Nomura <[email protected]>
commit b7e94a1686c5daef4f649f7f4f839cc294f07710 upstream.
block congestion control doesn't have any concept of fairness across multiple queues. This means that if SCSI reports the host as busy in the queue congestion control it can result in an unfair starvation situation in dm-mp if there are multiple multipath devices on the same host. For example:
http://www.redhat.com/archives/dm-devel/2012-May/msg00123.html
The fix for this is to report only the sdev busy state (and ignore the host busy state) in the block congestion control call back. The host is still congested, but the SCSI subsystem will sort out the congestion in a fair way because it knows the relation between the queues and the host.
--- drivers/scsi/scsi_lib.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
drivers/scsi/scsi_lib.c +7 -4
@@ -1378,16 +1378,19 @@ static int scsi_lld_busy(struct request_ {struct scsi_device *sdev = q->queuedata;struct Scsi_Host *shost; -struct scsi_target *starget;if (!sdev)return 0 ; shost = sdev->host; - starget =scsi_target (sdev); -if (scsi_host_in_recovery (shost) ||scsi_host_is_busy (shost) || -scsi_target_is_busy (starget) ||scsi_device_is_busy (sdev)) +/* +* Ignore host/starget busy state. +* Since block layer does not have a concept of fairness across +* multiple queues, congestion of host/starget needs to be handled +* in SCSI layer. +*/ +if (scsi_host_in_recovery (shost) ||scsi_device_is_busy (sdev))return 1 ;return 0 ;
Greg KH
maintainerPATCH 5/82 mm/fork: fix overflow in vma length when copying mmap on clone
In reply to Greg KH3.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Siddhesh Poyarekar <[email protected]>
commit 7edc8b0ac16cbaed7cb4ea4c6b95ce98d2997e84 upstream.
The vma length in dup_mmap is calculated and stored in a unsigned int, which is insufficient and hence overflows for very large maps (beyond 16TB). The following program demonstrates this:
#include <stdio.h>
#include <unistd.h>
#include <sys/mman.h>
#define GIG 1024 * 1024 * 1024L
#define EXTENT 16393
int main(void)
{
int i, r;
void *m;
char buf[1024];
for (i = 0; i < EXTENT; i++) {
m = mmap(NULL, (size_t) 1 * 1024 * 1024 * 1024L,
PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);
if (m == (void *)-1)
printf("MMAP Failed: %d\n", m);
else
printf("%d : MMAP returned %p\n", i, m);
r = fork();
if (r == 0) {
printf("%d: successed\n", i);
return 0;
} else if (r < 0)
printf("FORK Failed: %d\n", r);
else if (r > 0)
wait(NULL);
}
return 0;
}Increase the storage size of the result to unsigned long, which is sufficient for storing the difference between addresses.
--- kernel/fork.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/fork.c +2 -1
@@ -356,7 +356,8 @@ static int dup_mmap(struct mm_struct *mm } charge =0 ;if (mpnt->vm_flags &VM_ACCOUNT ) { -unsigned int len = (mpnt->vm_end - mpnt->vm_start) >>PAGE_SHIFT ; +unsigned long len; + len = (mpnt->vm_end - mpnt->vm_start) >>PAGE_SHIFT ;if (security_vm_enough_memory_mm (oldmm, len))/* sic */ goto fail_nomem; charge = len;
Greg KH
maintainerPATCH 6/82 mm: fix NULL ptr deref when walking hugepages
In reply to Greg KH3.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sasha Levin <[email protected]>
commit 08fa29d916c6e271ad13978cd993e7238c68db97 upstream.
A missing validation of the value returned by find_vma() could cause a NULL ptr dereference when walking the pagetable.
This is triggerable from usermode by a simple user by trying to read a page info out of /proc/pid/pagemap which doesn't exist.
Introduced by commit 025c5b2451e4 ("thp: optimize away unnecessary page table locking").
--- fs/proc/task_mmu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/proc/task_mmu.c +1 -1
@@ -784,7 +784,7 @@ static int pagemap_pte_range(pmd_t *pmd,/* find the first VMA at or above 'addr' */ vma =find_vma (walk->mm, addr); -if (pmd_trans_huge_lock (pmd, vma) ==1 ) { +if (vma &&pmd_trans_huge_lock (pmd, vma) ==1 ) {for (; addr != end; addr +=PAGE_SIZE ) {unsigned long offset;
Greg KH
maintainerPATCH 7/82 mm: consider all swapped back pages in used-once logic
In reply to Greg KH3.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michal Hocko <[email protected]>
commit e48982734ea0500d1eba4f9d96195acc5406cad6 upstream.
Commit 645747462435 ("vmscan: detect mapped file pages used only once") made mapped pages have another round in inactive list because they might be just short lived and so we could consider them again next time. This heuristic helps to reduce pressure on the active list with a streaming IO worklods.
This patch fixes a regression introduced by this commit for heavy shmem based workloads because unlike Anon pages, which are excluded from this heuristic because they are usually long lived, shmem pages are handled as a regular page cache.
This doesn't work quite well, unfortunately, if the workload is mostly backed by shmem (in memory database sitting on 80% of memory) with a streaming IO in the background (backup - up to 20% of memory). Anon inactive list is full of (dirty) shmem pages when watermarks are hit. Shmem pages are kept in the inactive list (they are referenced) in the first round and it is hard to reclaim anything else so we reach lower scanning priorities very quickly which leads to an excessive swap out.
Let's fix this by excluding all swap backed pages (they tend to be long lived wrt. the regular page cache anyway) from used-once heuristic and rather activate them if they are referenced.
The customer's workload is shmem backed database (80% of RAM) and they are measuring transactions/s with an IO in the background (20%). Transactions touch more or less random rows in the table. The transaction rate fell by a factor of 3 (in the worst case) because of commit 64574746. This patch restores the previous numbers.
--- mm/vmscan.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mm/vmscan.c +1 -1
@@ -722,7 +722,7 @@ static enum page_references page_check_rreturn PAGEREF_RECLAIM ;if (referenced_ptes) { -if (PageAnon (page)) +if (PageSwapBacked (page))return PAGEREF_ACTIVATE ;/* * All mapped pages start out with page table
Greg KH
maintainerPATCH 8/82 mm: pmd_read_atomic: fix 32bit PAE pmd walk vs pmd_populate SMP race condition
In reply to Greg KH3.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andrea Arcangeli <[email protected]>
commit 26c191788f18129af0eb32a358cdaea0c7479626 upstream.
When holding the mmap_sem for reading, pmd_offset_map_lock should only run on a pmd_t that has been read atomically from the pmdp pointer, otherwise we may read only half of it leading to this crash.
PID: 11679 TASK: f06e8000 CPU: 3 COMMAND: "do_race_2_panic"
#0 [f06a9dd8] crash_kexec at c049b5ec
#1 [f06a9e2c] oops_end at c083d1c2
#2 [f06a9e40] no_context at c0433ded
#3 [f06a9e64] bad_area_nosemaphore at c043401a #4 [f06a9e6c] __do_page_fault at c0434493
#5 [f06a9eec] do_page_fault at c083eb45
#6 [f06a9f04] error_code (via page_fault) at c083c5d5
EAX: 01fb470c EBX: fff35000 ECX: 00000003 EDX: 00000100 EBP:
00000000
DS: 007b ESI: 9e201000 ES: 007b EDI: 01fb4700 GS: 00e0
CS: 0060 EIP: c083bc14 ERR: ffffffff EFLAGS: 00010246
#7 [f06a9f38] _spin_lock at c083bc14
#8 [f06a9f44] sys_mincore at c0507b7d
#9 [f06a9fb0] system_call at c083becd
start len
EAX: ffffffda EBX: 9e200000 ECX: 00001000 EDX: 6228537f
DS: 007b ESI: 00000000 ES: 007b EDI: 003d0f00
SS: 007b ESP: 62285354 EBP: 62285388 GS: 0033
CS: 0073 EIP: 00291416 ERR: 000000da EFLAGS: 00000286This should be a longstanding bug affecting x86 32bit PAE without THP. Only archs with 64bit large pmd_t and 32bit unsigned long should be affected.
With THP enabled the barrier() in pmd_none_or_trans_huge_or_clear_bad() would partly hide the bug when the pmd transition from none to stable, by forcing a re-read of the *pmd in pmd_offset_map_lock, but when THP is enabled a new set of problem arises by the fact could then transition freely in any of the none, pmd_trans_huge or pmd_trans_stable states. So making the barrier in pmd_none_or_trans_huge_or_clear_bad() unconditional isn't good idea and it would be a flakey solution.
This should be fully fixed by introducing a pmd_read_atomic that reads the pmd in order with THP disabled, or by reading the pmd atomically with cmpxchg8b with THP enabled.
Luckily this new race condition only triggers in the places that must already be covered by pmd_none_or_trans_huge_or_clear_bad() so the fix is localized there but this bug is not related to THP.
NOTE: this can trigger on x86 32bit systems with PAE enabled with more than 4G of ram, otherwise the high part of the pmd will never risk to be truncated because it would be zero at all times, in turn so hiding the SMP race.
This bug was discovered and fully debugged by Ulrich, quote:
----
[..]pmd_none_or_trans_huge_or_clear_bad() loads the content of edx and eax.
496 static inline int pmd_none_or_trans_huge_or_clear_bad(pmd_t
*pmd)
497 {
498 /* depend on compiler for an atomic pmd read */
499 pmd_t pmdval = *pmd;
// edi = pmd pointer
0xc0507a74 <sys_mincore+548>: mov 0x8(%esp),%edi
...
// edx = PTE page table high address
0xc0507a84 <sys_mincore+564>: mov 0x4(%edi),%edx
...
// eax = PTE page table low address0xc0507a8e <sys_mincore+574>: mov (%edi),%eax
[..]
Please note that the PMD is not read atomically. These are two "mov" instructions where the high order bits of the PMD entry are fetched first. Hence, the above machine code is prone to the following race.
- The PMD entry {high|low} is 0x0000000000000000. The "mov" at 0xc0507a84 loads 0x00000000 into edx.
- A page fault (on another CPU) sneaks in between the two "mov" instructions and instantiates the PMD.
- The PMD entry {high|low} is now 0x00000003fda38067. The "mov" at 0xc0507a8e loads 0xfda38067 into eax.
----
--- arch/x86/include/asm/pgtable-3level.h | 50 ++++++++++++++++++++++++++++++++++ include/asm-generic/pgtable.h | 22 +++++++++++++- 2 files changed, 70 insertions(+), 2 deletions(-)
arch/x86/include/asm/pgtable-3level.h +50 -0
@@ -31,6 +31,56 @@ static inline void native_set_pte(pte_t ptep->pte_low = pte.pte_low; } +#define pmd_read_atomic pmd_read_atomic +/* +* pte_offset_map_lock on 32bit PAE kernels was reading the pmd_t with +* a "*pmdp" dereference done by gcc. Problem is, in certain places +* where pte_offset_map_lock is called, concurrent page faults are +* allowed, if the mmap_sem is hold for reading. An example is mincore +* vs page faults vs MADV_DONTNEED. On the page fault side +* pmd_populate rightfully does a set_64bit, but if we're reading the +* pmd_t with a "*pmdp" on the mincore side, a SMP race can happen +* because gcc will not read the 64bit of the pmd atomically. To fix +* this all places running pmd_offset_map_lock() while holding the +* mmap_sem in read mode, shall read the pmdp pointer using this +* function to know if the pmd is null nor not, and in turn to know if +* they can run pmd_offset_map_lock or pmd_trans_huge or other pmd +* operations. +* +* Without THP if the mmap_sem is hold for reading, the +* pmd can only transition from null to not null while pmd_read_atomic runs. +* So there's no need of literally reading it atomically. +* +* With THP if the mmap_sem is hold for reading, the pmd can become +* THP or null or point to a pte (and in turn become "stable") at any +* time under pmd_read_atomic, so it's mandatory to read it atomically +* with cmpxchg8b. +*/ +#ifndef CONFIG_TRANSPARENT_HUGEPAGE +static inline pmd_t pmd_read_atomic (pmd_t *pmdp) +{ +pmdval_t ret; +u32 *tmp = (u32 *)pmdp; + + ret = (pmdval_t) (*tmp); +if (ret) { +/* +* If the low part is null, we must not read the high part +* or we can end up with a partial pmd. +*/ +smp_rmb (); + ret |= ((pmdval_t)*(tmp +1 )) <<32 ; + } + +return (pmd_t ) { ret }; +} +#else /* CONFIG_TRANSPARENT_HUGEPAGE */ +static inline pmd_t pmd_read_atomic (pmd_t *pmdp) +{ +return (pmd_t ) {atomic64_read ((atomic64_t *)pmdp) }; +} +#endif /* CONFIG_TRANSPARENT_HUGEPAGE */ +static inline void native_set_pte_atomic (pte_t *ptep,pte_t pte) {set_64bit ((unsigned long long *)(ptep),native_pte_val (pte));
include/asm-generic/pgtable.h +20 -2
@@ -446,6 +446,18 @@ static inline int pmd_write(pmd_t pmd)#endif /* __HAVE_ARCH_PMD_WRITE */ #endif /* CONFIG_TRANSPARENT_HUGEPAGE */ +#ifndef pmd_read_atomic +static inline pmd_t pmd_read_atomic (pmd_t *pmdp) +{ +/* +* Depend on compiler for an atomic pmd read. NOTE: this is +* only going to work, if the pmdval_t isn't larger than +* an unsigned long. +*/ +return *pmdp; +} +#endif +/* * This function is meant to be used by sites walking pagetables with * the mmap_sem hold in read mode to protect against MADV_DONTNEED and
@@ -459,11 +471,17 @@ static inline int pmd_write(pmd_t pmd)* undefined so behaving like if the pmd was none is safe (because it * can return none anyway). The compiler level barrier() is critically * important to compute the two checks atomically on the same pmdval. +* +* For 32bit kernels with a 64bit large pmd_t this automatically takes +* care of reading the pmd atomically to avoid SMP race conditions +* against pmd_populate() when the mmap_sem is hold for reading by the +* caller (a special atomic read not done by "gcc" as in the generic +* version above, is also needed when THP is disabled because the page +* fault can populate the pmd from under us). */ static inline int pmd_none_or_trans_huge_or_clear_bad (pmd_t *pmd) { -/* depend on compiler for an atomic pmd read */ -pmd_t pmdval = *pmd; +pmd_t pmdval =pmd_read_atomic (pmd);/* * The barrier will stabilize the pmdval in a register or on * the stack so that it will stop changing under the code.
Greg KH
maintainerPATCH 9/82 mm: fix faulty initialization in vmalloc_init()
In reply to Greg KH3.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: KyongHo <[email protected]>
commit dbda591d920b4c7692725b13e3f68ecb251e9080 upstream.
The transfer of ->flags causes some of the static mapping virtual addresses to be prematurely freed (before the mapping is removed) because VM_LAZY_FREE gets "set" if tmp->flags has VM_IOREMAP set. This might cause subsequent vmalloc/ioremap calls to fail because it might allocate one of the freed virtual address ranges that aren't unmapped.
va->flags has different types of flags from tmp->flags. If a region with VM_IOREMAP set is registered with vm_area_add_early(), it will be removed by __purge_vmap_area_lazy().
Fix vmalloc_init() to correctly initialize vmap_area for the given vm_struct.
Also initialise va->vm. If it is not set, find_vm_area() for the early vm regions will always fail.
--- mm/vmalloc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
mm/vmalloc.c +2 -1
@@ -1185,9 +1185,10 @@ void __init vmalloc_init(void)/* Import existing vmlist entries. */ for (tmp = vmlist; tmp; tmp = tmp->next) { va =kzalloc (sizeof (struct vmap_area ),GFP_NOWAIT ); - va->flags = tmp->flags |VM_VM_AREA ; + va->flags =VM_VM_AREA ; va->va_start = (unsigned long )tmp->addr; va->va_end = va->va_start + tmp->size; + va->vm = tmp;__insert_vmap_area (va); }
Greg KH
maintainerPATCH 10/82 iwlwifi: update BT traffic load states correctly
In reply to Greg KH3.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Meenakshi Venkataraman <[email protected]>
commit 882dde8eb0d49ce0f853f8f4084dde56a21fe55f upstream.
When BT traffic load changes from its
previous state, a new LQ command needs to be
sent down to the firmware. This needs to
be done only once per change. The state
variable that keeps track of this change islast_bt_traffic_load. However, it was not
being updated when the change had been
handled. Not updating this variable was
causing a flood of advanced BT config
commands to be sent to the firmware. Fix
this.
--- drivers/net/wireless/iwlwifi/iwl-agn-rs.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/wireless/iwlwifi/iwl-agn-rs.c +1 -0
@@ -884,6 +884,7 @@ static void rs_bt_update_lq(struct iwl_pif ((priv->bt_traffic_load != priv->last_bt_traffic_load) || (priv->bt_full_concurrent != full_concurrent)) { priv->bt_full_concurrent = full_concurrent; + priv->last_bt_traffic_load = priv->bt_traffic_load;/* Update uCode's rate table. */ tbl = &(lq_sta->lq_info[lq_sta->active_tbl]);
Greg KH
maintainerPATCH 11/82 iwlwifi: do not use shadow registers by default
In reply to Greg KH3.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Meenakshi Venkataraman <[email protected]>
commit 66a770729a5cdd24efed8afa5258f81232d8bba2 upstream.
Shadow registers in the device are meant to
allow the driver to update certain device
registers without needing to wake up all
components of the device. However, using
this feature in the device causes
communication between the driver and the
device to become unreliable, resulting in
host command timeouts.
Disable this feature by default till a fix is
available for the bug.
--- drivers/net/wireless/iwlwifi/iwl-2000.c | 4 ++-- drivers/net/wireless/iwlwifi/iwl-6000.c | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-)
drivers/net/wireless/iwlwifi/iwl-2000.c +2 -2
@@ -183,7 +183,7 @@ static const struct iwl_base_params iwl2 .chain_noise_scale = 1000, .wd_timeout = IWL_DEF_WD_TIMEOUT, .max_event_log_size = 512, - .shadow_reg_enable = true, + .shadow_reg_enable = false, /* TODO: fix bugs using this feature */ .hd_v2 = true, };
@@ -202,7 +202,7 @@ static const struct iwl_base_params iwl2 .chain_noise_scale = 1000, .wd_timeout = IWL_LONG_WD_TIMEOUT, .max_event_log_size = 512, - .shadow_reg_enable = true, + .shadow_reg_enable = false, /* TODO: fix bugs using this feature */ .hd_v2 = true, };
drivers/net/wireless/iwlwifi/iwl-6000.c +3 -3
@@ -282,7 +282,7 @@ static const struct iwl_base_params iwl6 .chain_noise_scale = 1000, .wd_timeout = IWL_DEF_WD_TIMEOUT, .max_event_log_size = 512, - .shadow_reg_enable = true, + .shadow_reg_enable = false, /* TODO: fix bugs using this feature */ };static const struct iwl_base_params iwl6050_base_params = {
@@ -299,7 +299,7 @@ static const struct iwl_base_params iwl6 .chain_noise_scale = 1500, .wd_timeout = IWL_DEF_WD_TIMEOUT, .max_event_log_size = 1024, - .shadow_reg_enable = true, + .shadow_reg_enable = false, /* TODO: fix bugs using this feature */ };static const struct iwl_base_params iwl6000_g2_base_params = {
@@ -316,7 +316,7 @@ static const struct iwl_base_params iwl6 .chain_noise_scale = 1000, .wd_timeout = IWL_LONG_WD_TIMEOUT, .max_event_log_size = 512, - .shadow_reg_enable = true, + .shadow_reg_enable = false, /* TODO: fix bugs using this feature */ };static const struct iwl_ht_params iwl6000_ht_params = {
Greg KH
maintainerPATCH 12/82 cifs: Include backup intent search flags during searches {try #2)
In reply to Greg KH3.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shirish Pargaonkar <[email protected]>
commit 2608bee744a92d60d15ff4e6e0b913d8b406aedd upstream.
As observed and suggested by Tushar Gosavi...
---------
readdir calls these function to send TRANS2_FIND_FIRST and TRANS2_FIND_NEXT command to the server. The current cifs module is not specifying CIFS_SEARCH_BACKUP_SEARCH flag while sending these command when backupuid/backupgid is specified. This can be resolved by specifying CIFS_SEARCH_BACKUP_SEARCH flag.
---------
--- fs/cifs/cifsproto.h | 6 ++++-- fs/cifs/cifssmb.c | 12 +++++------- fs/cifs/readdir.c | 15 +++++++++++++-- 3 files changed, 22 insertions(+), 11 deletions(-)
fs/cifs/cifsproto.h +4 -2
@@ -192,11 +192,13 @@ extern int CIFSTCon(unsigned int xid, stextern int CIFSFindFirst (const int xid,struct cifs_tcon *tcon,const char *searchName,const struct nls_table *nls_codepage, -__u16 *searchHandle,struct cifs_search_info *psrch_inf, +__u16 *searchHandle,__u16 search_flags, +struct cifs_search_info *psrch_inf,int map,const char dirsep);extern int CIFSFindNext (const int xid,struct cifs_tcon *tcon, -__u16 searchHandle,struct cifs_search_info *psrch_inf); +__u16 searchHandle,__u16 search_flags, +struct cifs_search_info *psrch_inf);extern int CIFSFindClose (const int ,struct cifs_tcon *tcon,const __u16 search_handle);
fs/cifs/cifssmb.c +5 -7
@@ -4344,7 +4344,7 @@ int CIFSFindFirst(const int xid, struct cifs_tcon *tcon, const char *searchName, const struct nls_table *nls_codepage, - __u16 *pnetfid, + __u16 *pnetfid, __u16 search_flags, struct cifs_search_info *psrch_inf, int remap, const char dirsep) {/* level 257 SMB_ */
@@ -4416,8 +4416,7 @@ findFirstRetry:cpu_to_le16 (ATTR_READONLY |ATTR_HIDDEN |ATTR_SYSTEM |ATTR_DIRECTORY ); pSMB->SearchCount =cpu_to_le16 (CIFSMaxBufSize/sizeof (FILE_UNIX_INFO )); - pSMB->SearchFlags =cpu_to_le16 (CIFS_SEARCH_CLOSE_AT_END | -CIFS_SEARCH_RETURN_RESUME ); + pSMB->SearchFlags =cpu_to_le16 (search_flags); pSMB->InformationLevel =cpu_to_le16 (psrch_inf->info_level);/* BB what should we set StorageType to? Does it matter? BB */
@@ -4487,8 +4486,8 @@ findFirstRetry:return rc; } -int CIFSFindNext (const int xid,struct cifs_tcon *tcon, -__u16 searchHandle,struct cifs_search_info *psrch_inf) +int CIFSFindNext (const int xid,struct cifs_tcon *tcon,__u16 searchHandle, +__u16 search_flags,struct cifs_search_info *psrch_inf) {TRANSACTION2_FNEXT_REQ *pSMB =NULL ;TRANSACTION2_FNEXT_RSP *pSMBr =NULL ;
@@ -4531,8 +4530,7 @@ int CIFSFindNext(const int xid, struct ccpu_to_le16 (CIFSMaxBufSize /sizeof (FILE_UNIX_INFO )); pSMB->InformationLevel =cpu_to_le16 (psrch_inf->info_level); pSMB->ResumeKey = psrch_inf->resume_key; - pSMB->SearchFlags = -cpu_to_le16 (CIFS_SEARCH_CLOSE_AT_END |CIFS_SEARCH_RETURN_RESUME ); + pSMB->SearchFlags =cpu_to_le16 (search_flags); name_len = psrch_inf->resume_name_len; params += name_len;
fs/cifs/readdir.c +13 -2
@@ -219,6 +219,7 @@ int get_symlink_reparse_path(char *full_static int initiate_cifs_search (const int xid,struct file *file) { +__u16 search_flags;int rc =0 ;char *full_path =NULL ;struct cifsFileInfo *cifsFile;
@@ -270,8 +271,12 @@ ffirst_retry: cifsFile->srch_inf.info_level =SMB_FIND_FILE_DIRECTORY_INFO ; } + search_flags =CIFS_SEARCH_CLOSE_AT_END |CIFS_SEARCH_RETURN_RESUME ; +if (backup_cred (cifs_sb)) + search_flags |=CIFS_SEARCH_BACKUP_SEARCH ; + rc =CIFSFindFirst (xid, pTcon, full_path, cifs_sb->local_nls, - &cifsFile->netfid, &cifsFile->srch_inf, + &cifsFile->netfid, search_flags, &cifsFile->srch_inf, cifs_sb->mnt_cifs_flags &CIFS_MOUNT_MAP_SPECIAL_CHR ,CIFS_DIR_SEP (cifs_sb));if (rc ==0 )
@@ -502,11 +507,13 @@ static int cifs_save_resume_key(const chstatic int find_cifs_entry (const int xid,struct cifs_tcon *pTcon,struct file *file,char **ppCurrentEntry,int *num_to_ret) { +__u16 search_flags;int rc =0 ;int pos_in_buf =0 ;loff_t first_entry_in_buffer;loff_t index_to_find = file->f_pos;struct cifsFileInfo *cifsFile = file->private_data; +struct cifs_sb_info *cifs_sb =CIFS_SB (file->f_path.dentry->d_sb);/* check if index in the buffer */ if ((cifsFile == NULL) || (ppCurrentEntry == NULL) ||
@@ -560,10 +567,14 @@ static int find_cifs_entry(const int xid cifsFile); } + search_flags =CIFS_SEARCH_CLOSE_AT_END |CIFS_SEARCH_RETURN_RESUME ; +if (backup_cred (cifs_sb)) + search_flags |=CIFS_SEARCH_BACKUP_SEARCH ; +while ((index_to_find >= cifsFile->srch_inf.index_of_last_entry) && (rc ==0 ) && !cifsFile->srch_inf.endOfSearch) {cFYI (1 ,"calling findnext2" ); - rc =CIFSFindNext (xid, pTcon, cifsFile->netfid, + rc =CIFSFindNext (xid, pTcon, cifsFile->netfid, search_flags, &cifsFile->srch_inf);/* FindFirst/Next set last_entry to NULL on malformed reply */ if (cifsFile->srch_inf.last_entry)
Greg KH
maintainerPATCH 13/82 cifs: fix oops while traversing open file list (try #4)
In reply to Greg KH3.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shirish Pargaonkar <[email protected]>
commit 2c0c2a08bed7a3b791f88d09d16ace56acb3dd98 upstream.
While traversing the linked list of open file handles, if the identfied file handle is invalid, a reopen is attempted and if it fails, we resume traversing where we stopped and cifs can oops while accessing invalid next element, for list might have changed.
So mark the invalid file handle and attempt reopen if no valid file handle is found in rest of the list.
If reopen fails, move the invalid file handle to the end of the list and start traversing the list again from the begining. Repeat this four times before giving up and returning an error if file reopen keeps failing.
--- fs/cifs/cifsglob.h | 1 fs/cifs/file.c | 57 ++++++++++++++++++++++++++++++----------------------- 2 files changed, 34 insertions(+), 24 deletions(-)
fs/cifs/cifsglob.h +1 -0
@@ -43,6 +43,7 @@#define CIFS_MIN_RCV_POOL 4 +#define MAX_REOPEN_ATT 5/* these many maximum attempts to reopen a file */ /* * default attribute cache timeout (jiffies) */
fs/cifs/file.c +33 -24
90 lines not on this page · raw message
Greg KH
maintainerPATCH 14/82 PARISC: fix boot failure on 32-bit systems caused by branch stubs placed before .text
In reply to Greg KH3.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: John David Anglin <[email protected]>
commit ed5fb2471b7060767957fb964eb1aaec71533ab1 upstream.
In certain configurations, the resulting kernel becomes too large to boot because the linker places the long branch stubs for the merged .text section at the very start of the image. As a result, the initial transfer of control jumps to an unexpected location. Fix this by placing the head text in a separate section so the stubs for .text are not at the start of the image.
--- arch/parisc/kernel/vmlinux.lds.S | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
arch/parisc/kernel/vmlinux.lds.S +4 -2
@@ -50,8 +50,10 @@ SECTIONS . = KERNEL_BINARY_TEXT_START; _text = .; /* Text and read-only data */ - .text ALIGN(16) : { + .head ALIGN(16) : { HEAD_TEXT + } = 0 + .text ALIGN(16) : { TEXT_TEXT SCHED_TEXT LOCK_TEXT
@@ -65,7 +67,7 @@ SECTIONS *(.fixup) *(.lock.text) /* out-of-line lock text */ *(.gnu.warning) - } = 0 + } /* End of text section */ _etext = .;
Greg KH
maintainerPATCH 15/82 PARISC: fix TLB fault path on PA2.0 narrow systems
In reply to Greg KH3.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: James Bottomley <[email protected]>
commit 2f649c1f6f0fef445ce79a19b79e5ce8fe9d7f19 upstream.
commit 5e185581d7c46ddd33cd9c01106d1fc86efb9376
Author: James Bottomley <[email protected]>
[PARISC] fix PA1.1 oops on boot
Didn't quite fix the crash on boot. It moved it from PA1.1 processors to PA2.0 narrow kernels. The final fix is to make sure the [id]tlb_miss_20 paths also work. Even on narrow systems, these paths require using the wide instructions becuase the tlb insertion format is wide. Fix this by conditioning the dep[wd],z on whether we're being called from _11 or _20[w] paths.
--- arch/parisc/kernel/entry.S | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-)
arch/parisc/kernel/entry.S +17 -13
@@ -552,7 +552,7 @@ * entry (identifying the physical page) and %r23 up with * the from tlb entry (or nothing if only a to entry---for * clear_user_page_asm) */ - .macro do_alias spc,tmp,tmp1,va,pte,prot,fault + .macro do_alias spc,tmp,tmp1,va,pte,prot,fault,patype cmpib,COND(<>),n 0,\spc,\fault ldil L%(TMPALIAS_MAP_START),\tmp #if defined(CONFIG_64BIT) && (TMPALIAS_MAP_START >= 0x80000000)
@@ -581,11 +581,15 @@ */ cmpiclr,= 0x01,\tmp,%r0 ldi (_PAGE_DIRTY|_PAGE_READ|_PAGE_WRITE),\prot -#ifdef CONFIG_64BIT +.ifc \patype,20 depd,z \prot,8,7,\prot -#else +.else +.ifc \patype,11 depw,z \prot,8,7,\prot -#endif +.else + .error "undefined PA type to do_alias" +.endif +.endif /* * OK, it is in the temp alias region, check whether "from" or "to". * Check "subtle" note in pacache.S re: r23/r26.
@@ -1189,7 +1193,7 @@ dtlb_miss_20w: nop dtlb_check_alias_20w: - do_alias spc,t0,t1,va,pte,prot,dtlb_fault + do_alias spc,t0,t1,va,pte,prot,dtlb_fault,20 idtlbt pte,prot
@@ -1213,7 +1217,7 @@ nadtlb_miss_20w: nop nadtlb_check_alias_20w: - do_alias spc,t0,t1,va,pte,prot,nadtlb_emulate + do_alias spc,t0,t1,va,pte,prot,nadtlb_emulate,20 idtlbt pte,prot
@@ -1245,7 +1249,7 @@ dtlb_miss_11: nop dtlb_check_alias_11: - do_alias spc,t0,t1,va,pte,prot,dtlb_fault + do_alias spc,t0,t1,va,pte,prot,dtlb_fault,11 idtlba pte,(va) idtlbp prot,(va)
@@ -1277,7 +1281,7 @@ nadtlb_miss_11: nop nadtlb_check_alias_11: - do_alias spc,t0,t1,va,pte,prot,nadtlb_emulate + do_alias spc,t0,t1,va,pte,prot,nadtlb_emulate,11 idtlba pte,(va) idtlbp prot,(va)
@@ -1304,7 +1308,7 @@ dtlb_miss_20: nop dtlb_check_alias_20: - do_alias spc,t0,t1,va,pte,prot,dtlb_fault + do_alias spc,t0,t1,va,pte,prot,dtlb_fault,20 idtlbt pte,prot
@@ -1330,7 +1334,7 @@ nadtlb_miss_20: nop nadtlb_check_alias_20: - do_alias spc,t0,t1,va,pte,prot,nadtlb_emulate + do_alias spc,t0,t1,va,pte,prot,nadtlb_emulate,20 idtlbt pte,prot
@@ -1457,7 +1461,7 @@ naitlb_miss_20w: nop naitlb_check_alias_20w: - do_alias spc,t0,t1,va,pte,prot,naitlb_fault + do_alias spc,t0,t1,va,pte,prot,naitlb_fault,20 iitlbt pte,prot
@@ -1511,7 +1515,7 @@ naitlb_miss_11: nop naitlb_check_alias_11: - do_alias spc,t0,t1,va,pte,prot,itlb_fault + do_alias spc,t0,t1,va,pte,prot,itlb_fault,11 iitlba pte,(%sr0, va) iitlbp prot,(%sr0, va)
@@ -1557,7 +1561,7 @@ naitlb_miss_20: nop naitlb_check_alias_20: - do_alias spc,t0,t1,va,pte,prot,naitlb_fault + do_alias spc,t0,t1,va,pte,prot,naitlb_fault,20 iitlbt pte,prot
Greg KH
maintainerPATCH 16/82 solos-pci: Fix DMA support
In reply to Greg KH3.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Woodhouse <[email protected]>
commit b4bd8ad9bb311e8536f726f7a633620ccd358cde upstream.
DMA support has finally made its way to the top of the TODO list, having realised that a Geode using MMIO can't keep up with two ADSL2+ lines each running at 21Mb/s.
This patch fixes a couple of bugs in the DMA support in the driver, so once the corresponding FPGA update is complete and tested everything should work properly.
We weren't storing the currently-transmitting skb, so we were never unmapping it and never freeing/popping it when the TX was done. And the addition of pci_set_master() is fairly self-explanatory.
--- drivers/atm/solos-pci.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/atm/solos-pci.c +3 -1
@@ -984,6 +984,7 @@ static uint32_t fpga_tx(struct solos_car }else if (skb && card->using_dma) {SKB_CB (skb)->dma_addr =pci_map_single (card->dev, skb->data, skb->len,PCI_DMA_TODEVICE ); + card->tx_skb[port] = skb;iowrite32 (SKB_CB (skb)->dma_addr, card->config_regs +TX_DMA_ADDR (port)); }
@@ -1152,7 +1153,8 @@ static int fpga_probe(struct pci_dev *de db_fpga_upgrade = db_firmware_upgrade =0 ; } -if (card->fpga_version >=DMA_SUPPORTED ){ +if (card->fpga_version >=DMA_SUPPORTED ) { +pci_set_master (dev); card->using_dma =1 ; }else { card->using_dma =0 ;
Greg KH
maintainerPATCH 17/82 MIPS: BCM63XX: Add missing include for bcm63xx_gpio.h
In reply to Greg KH3.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jonas Gorski <[email protected]>
commit 442209f31dafef9fde852858e1ce566b675b720d upstream.
bcm63xx_gpio.h uses macros defined in bcm63xx_cpu.h without including it, leading to the following build failure:
CC [M] drivers/mmc/core/cd-gpio.o
In file included from arch/mips/include/asm/mach-bcm63xx/gpio.h:4:0,
from arch/mips/include/asm/gpio.h:4,
from include/linux/gpio.h:30,
from drivers/mmc/core/cd-gpio.c:12:arch/mips/include/asm/mach-bcm63xx/bcm63xx_gpio.h: In function 'bcm63xx_gpio_count':arch/mips/include/asm/mach-bcm63xx/bcm63xx_gpio.h:10:2: error: implicit declaration of function 'bcm63xx_get_cpu_id' arch/mips/include/asm/mach-bcm63xx/bcm63xx_gpio.h:11:7: error: 'BCM6358_CPU_ID' undeclared (first use in this function) arch/mips/include/asm/mach-bcm63xx/bcm63xx_gpio.h:11:7: note: each undeclared identifier is reported only once for each function it appears in arch/mips/include/asm/mach-bcm63xx/bcm63xx_gpio.h:13:7: error: 'BCM6338_CPU_ID' undeclared (first use in this function) arch/mips/include/asm/mach-bcm63xx/bcm63xx_gpio.h:15:7: error: 'BCM6345_CPU_ID' undeclared (first use in this function) arch/mips/include/asm/mach-bcm63xx/bcm63xx_gpio.h:17:7: error: 'BCM6368_CPU_ID' undeclared (first use in this function) arch/mips/include/asm/mach-bcm63xx/bcm63xx_gpio.h:19:7: error: 'BCM6348_CPU_ID' undeclared (first use in this function)
make[7]: *** [drivers/mmc/core/cd-gpio.o] Error 1
--- arch/mips/include/asm/mach-bcm63xx/bcm63xx_gpio.h | 1 + 1 file changed, 1 insertion(+)
arch/mips/include/asm/mach-bcm63xx/bcm63xx_gpio.h +1 -0
@@ -2,6 +2,7 @@#define BCM63XX_GPIO_H #include <linux/init.h> +#include <bcm63xx_cpu.h> int __init bcm63xx_gpio_init (void );
Greg KH
maintainerPATCH 18/82 mac80211: fix ADDBA declined after suspend with wowlan
In reply to Greg KH3.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eyal Shapira <[email protected]>
commit 7b21aea04d084916ac4e0e8852dcc9cd60ec0d1d upstream.
WLAN_STA_BLOCK_BA is set while suspending but doesn't get cleared when resuming in case of wowlan. This causes further ADDBA requests received to be rejected. Fix it by clearing it in the wowlan path as well.
--- net/mac80211/util.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
net/mac80211/util.c +6 -6
@@ -1321,6 +1321,12 @@ int ieee80211_reconfig(struct ieee80211_ } } +/* add back keys */ +list_for_each_entry (sdata, &local->interfaces, list) +if (ieee80211_sdata_running (sdata)) +ieee80211_enable_keys (sdata); + + wake_up:/* * Clear the WLAN_STA_BLOCK_BA flag so new aggregation * sessions can be established after a resume.
@@ -1342,12 +1348,6 @@ int ieee80211_reconfig(struct ieee80211_mutex_unlock (&local->sta_mtx); } -/* add back keys */ -list_for_each_entry (sdata, &local->interfaces, list) -if (ieee80211_sdata_running (sdata)) -ieee80211_enable_keys (sdata); - - wake_up:ieee80211_wake_queues_by_reason (hw,IEEE80211_QUEUE_STOP_REASON_SUSPEND );
Greg KH
maintainerPATCH 19/82 ixp4xx: fix compilation by adding gpiolib support
In reply to Greg KH3.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Richard Cochran <[email protected]>
commit 9dde0ae3769875ec1370cb316e50c54b57d52c1a upstream.
Once again, ixp4xx no longer even compiles. This patch fixes the issue by converting over to gpiolib. This patch was first made by Imre and posted by Marc, and I added in Russell's suggestion to empty the gpio header file.
This fix should also go for 3.1, 3.2, 3.3, and 3.4.
--- arch/arm/Kconfig | 2 arch/arm/mach-ixp4xx/common.c | 48 ++++++++++++++++++ arch/arm/mach-ixp4xx/include/mach/gpio.h | 79 ------------------------------- 3 files changed, 48 insertions(+), 81 deletions(-)
arch/arm/Kconfig +1 -1
@@ -556,7 +556,7 @@ config ARCH_IXP4XX select ARCH_HAS_DMA_SET_COHERENT_MASK select CLKSRC_MMIO select CPU_XSCALE - select GENERIC_GPIO + select ARCH_REQUIRE_GPIOLIB select GENERIC_CLOCKEVENTS select MIGHT_HAVE_PCI select NEED_MACH_IO_H
arch/arm/mach-ixp4xx/common.c +46 -2
78 lines not on this page · raw message
arch/arm/mach-ixp4xx/include/mach/gpio.h +1 -78
80 lines not on this page · raw message
Greg KH
maintainerPATCH 20/82 ath9k: fix a use-after-free-bug when ath_tx_setup_buffer() fails
In reply to Greg KH3.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Felix Fietkau <[email protected]>
commit 81357a281dcc454841532c46b30e6f2ba12b73ea upstream.
ath_tx_setup_buffer() can fail if there is no ath_buf left, or if mapping DMA failed. In this case it frees the skb passed to it.
If ath_tx_setup_buffer is called from ath_tx_form_aggr, the skb is still linked into the tid buffer list and must be dequeued before being released.
--- drivers/net/wireless/ath/ath9k/xmit.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)
drivers/net/wireless/ath/ath9k/xmit.c +10 -6
@@ -64,7 +64,8 @@ static void ath_tx_update_baw(struct athstatic struct ath_buf *ath_tx_setup_buffer (struct ath_softc *sc,struct ath_txq *txq,struct ath_atx_tid *tid, -struct sk_buff *skb); +struct sk_buff *skb, +bool dequeue);enum {MCS_HT20 ,
@@ -811,7 +812,7 @@ static enum ATH_AGGR_STATUS ath_tx_form_ fi =get_frame_info (skb); bf = fi->bf;if (!fi->bf) - bf =ath_tx_setup_buffer (sc, txq, tid, skb); + bf =ath_tx_setup_buffer (sc, txq, tid, skb, true);if (!bf)continue ;
@@ -1726,7 +1727,7 @@ static void ath_tx_send_ampdu(struct athreturn ; } - bf =ath_tx_setup_buffer (sc, txctl->txq, tid, skb); + bf =ath_tx_setup_buffer (sc, txctl->txq, tid, skb, false);if (!bf)return ;
@@ -1753,7 +1754,7 @@ static void ath_tx_send_normal(struct at bf = fi->bf;if (!bf) - bf =ath_tx_setup_buffer (sc, txq, tid, skb); + bf =ath_tx_setup_buffer (sc, txq, tid, skb, false);if (!bf)return ;
@@ -1814,7 +1815,8 @@ u8 ath_txchainmask_reduction(struct ath_static struct ath_buf *ath_tx_setup_buffer (struct ath_softc *sc,struct ath_txq *txq,struct ath_atx_tid *tid, -struct sk_buff *skb) +struct sk_buff *skb, +bool dequeue) {struct ath_common *common =ath9k_hw_common (sc->sc_ah);struct ath_frame_info *fi =get_frame_info (skb);
@@ -1863,6 +1865,8 @@ static struct ath_buf *ath_tx_setup_buffreturn bf; error: +if (dequeue) +__skb_unlink (skb, &tid->buf_q);dev_kfree_skb_any (skb);return NULL ; }
@@ -1893,7 +1897,7 @@ static void ath_tx_start_dma(struct ath_*/ ath_tx_send_ampdu (sc, tid, skb, txctl); }else { - bf =ath_tx_setup_buffer (sc, txctl->txq, tid, skb); + bf =ath_tx_setup_buffer (sc, txctl->txq, tid, skb, false);if (!bf)return ;
Greg KH
maintainerPATCH 21/82 x86, amd, xen: Avoid NULL pointer paravirt references
In reply to Greg KH3.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Konrad Rzeszutek Wilk <[email protected]>
commit 1ab46fd319bcf1fcd9fb6311727d532b580e4eba upstream.
Stub out MSR methods that aren't actually needed. This fixes a crash as Xen Dom0 on AMD Trinity systems. A bigger patch should be added to remove the paravirt machinery completely for the methods which apparently have no users!
--- arch/x86/xen/enlighten.c | 3 +++ 1 file changed, 3 insertions(+)
arch/x86/xen/enlighten.c +3 -0
@@ -1106,7 +1106,10 @@ static const struct pv_cpu_ops xen_cpu_o .wbinvd = native_wbinvd, .read_msr = native_read_msr_safe, + .rdmsr_regs = native_rdmsr_safe_regs, .write_msr = xen_write_msr_safe, + .wrmsr_regs = native_wrmsr_safe_regs, + .read_tsc = native_read_tsc, .read_pmc = native_read_pmc,
Greg KH
maintainerPATCH 22/82 NFS: kmalloc() doesnt return an ERR_PTR()
In reply to Greg KH3.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
commit 5abc03cd919535c61b813f2319cb38326a41e810 upstream.
Obviously we should check for NULL here instead of IS_ERR().
--- fs/nfs/idmap.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)
fs/nfs/idmap.c +3 -7
@@ -640,20 +640,16 @@ static int nfs_idmap_legacy_upcall(strucstruct idmap_msg *im;struct idmap *idmap = (struct idmap *)aux;struct key *key = cons->key; -int ret; +int ret = -ENOMEM ;/* msg and im are freed in idmap_pipe_destroy_msg */ msg =kmalloc (sizeof (*msg),GFP_KERNEL ); -if (IS_ERR (msg)) { - ret =PTR_ERR (msg); +if (!msg) goto out0; - } im =kmalloc (sizeof (*im),GFP_KERNEL ); -if (IS_ERR (im)) { - ret =PTR_ERR (im); +if (!im) goto out1; - } ret =nfs_idmap_prepare_message (key->description, im, msg);if (ret <0 )
Greg KH
maintainerPATCH 23/82 NFSv4: Map NFS4ERR_SHARE_DENIED into an EACCES error instead of EIO
In reply to Greg KH3.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Trond Myklebust <[email protected]>
commit fb13bfa7e1bcfdcfdece47c24b62f1a1cad957e9 upstream.
If a file OPEN is denied due to a share lock, the resulting NFS4ERR_SHARE_DENIED is currently mapped to the default EIO. This patch adds a more appropriate mapping, and brings Linux into line with what Solaris 10 does.
See https://bugzilla.kernel.org/show_bug.cgi?id=43286
--- fs/nfs/nfs4proc.c | 2 ++ 1 file changed, 2 insertions(+)
fs/nfs/nfs4proc.c +2 -0
@@ -101,6 +101,8 @@ static int nfs4_map_errors(int err)case -NFS4ERR_BADOWNER :case -NFS4ERR_BADNAME :return -EINVAL ; +case -NFS4ERR_SHARE_DENIED : +return -EACCES ;default :dprintk ("%s could not handle NFSv4 error %d\n" , __func__, -err);
Greg KH
maintainerPATCH 24/82 hugetlb: fix resv_map leak in error path
In reply to Greg KH3.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Hansen <[email protected]>
commit c50ac050811d6485616a193eb0f37bfbd191cc89 upstream.
When called for anonymous (non-shared) mappings, hugetlb_reserve_pages() does a resv_map_alloc(). It depends on code in hugetlbfs's vm_ops->close() to release that allocation.
However, in the mmap() failure path, we do a plain unmap_region() without the remove_vma() which actually calls vm_ops->close().
This is a decent fix. This leak could get reintroduced if new code (say, after hugetlb_reserve_pages() in hugetlbfs_file_mmap()) decides to return an error. But, I think it would have to unroll the reservation anyway.
Christoph's test case:
http://marc.info/?l=linux-mm&m=133728900729735
This patch applies to 3.4 and later. A version for earlier kernels is at
https://lkml.org/lkml/2012/5/22/418.
--- mm/hugetlb.c | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-)
mm/hugetlb.c +22 -6
@@ -2157,6 +2157,15 @@ static void hugetlb_vm_op_open(struct vmkref_get (&reservations->refs); } +static void resv_map_put (struct vm_area_struct *vma) +{ +struct resv_map *reservations =vma_resv_map (vma); + +if (!reservations) +return ; +kref_put (&reservations->refs, resv_map_release); +} +static void hugetlb_vm_op_close (struct vm_area_struct *vma) {struct hstate *h =hstate_vma (vma);
@@ -2173,7 +2182,7 @@ static void hugetlb_vm_op_close(struct v reserve = (end - start) -region_count (&reservations->regions, start, end); -kref_put (&reservations->refs, resv_map_release); +resv_map_put (vma);if (reserve) {hugetlb_acct_memory (h, -reserve);
@@ -2990,12 +2999,16 @@ int hugetlb_reserve_pages(struct inode *set_vma_resv_flags (vma,HPAGE_RESV_OWNER ); } -if (chg <0 ) -return chg; +if (chg <0 ) { + ret = chg; + goto out_err; + }/* There must be enough pages in the subpool for the mapping */ -if (hugepage_subpool_get_pages (spool, chg)) -return -ENOSPC ; +if (hugepage_subpool_get_pages (spool, chg)) { + ret = -ENOSPC ; + goto out_err; + }/* * Check enough hugepages are available for the reservation.
@@ -3004,7 +3017,7 @@ int hugetlb_reserve_pages(struct inode * ret =hugetlb_acct_memory (h, chg);if (ret <0 ) {hugepage_subpool_put_pages (spool, chg); -return ret; + goto out_err; }/*
@@ -3021,6 +3034,9 @@ int hugetlb_reserve_pages(struct inode *if (!vma || vma->vm_flags &VM_MAYSHARE )region_add (&inode->i_mapping->private_list, from, to);return 0 ; +out_err: +resv_map_put (vma); +return ret; }void hugetlb_unreserve_pages (struct inode *inode,long offset,long freed)
Greg KH
maintainerPATCH 25/82 sunrpc: fix loss of task->tk_status after rpc_delay call in xprt_alloc_slot
In reply to Greg KH3.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Trond Myklebust <[email protected]>
commit 1afeaf5c29aa07db25760d2fbed5c08a3aec3498 upstream.
xprt_alloc_slot will call rpc_delay() to make the task wait a bit before retrying when it gets back an -ENOMEM error from xprt_dynamic_alloc_slot. The problem is that rpc_delay will clear the task->tk_status, causing call_reserveresult to abort the task.
The solution is simply to let call_reserveresult handle the ENOMEM error directly.
--- net/sunrpc/clnt.c | 2 ++ net/sunrpc/xprt.c | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-)
net/sunrpc/clnt.c +2 -0
@@ -1288,6 +1288,8 @@ call_reserveresult(struct rpc_task *task }switch (status) { +case -ENOMEM : +rpc_delay (task,HZ >>2 );case -EAGAIN :/* woken up; retry */ task->tk_action = call_reserve;return ;
net/sunrpc/xprt.c +3 -2
@@ -984,15 +984,16 @@ static void xprt_alloc_slot(struct rpc_t goto out_init_req;switch (PTR_ERR (req)) {case -ENOMEM : -rpc_delay (task,HZ >>2 );dprintk ("RPC: dynamic allocation of request slot " "failed! Retrying\n" ); + task->tk_status = -ENOMEM ;break ;case -EAGAIN :rpc_sleep_on (&xprt->backlog, task,NULL );dprintk ("RPC: waiting for request slot\n" ); +default : + task->tk_status = -EAGAIN ; } - task->tk_status = -EAGAIN ;return ; out_init_req: task->tk_status =0 ;
Greg KH
maintainerPATCH 26/82 iommu/amd: Check for the right TLP prefix bit
In reply to Greg KH3.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joerg Roedel <[email protected]>
commit a3b93121430c7b46c2895a7744261be107ccdf7f upstream.
Unfortunatly the PRI spec changed and moved the TLP-prefix-required bit to a different location. This patch makes the necessary change in the AMD IOMMU driver. Regressions are not expected because all hardware implementing the PRI capability sets this bit to zero anyway.
--- drivers/iommu/amd_iommu.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/iommu/amd_iommu.c +4 -4
@@ -2035,20 +2035,20 @@ out_err: }/* FIXME: Move this to PCI code */ -#define PCI_PRI_TLP_OFF (1 << 2) +#define PCI_PRI_TLP_OFF (1 << 15)bool pci_pri_tlp_required (struct pci_dev *pdev) { -u16 control; +u16 status;int pos; pos =pci_find_ext_capability (pdev,PCI_EXT_CAP_ID_PRI );if (!pos)return false; -pci_read_config_word (pdev, pos +PCI_PRI_CTRL , &control); +pci_read_config_word (pdev, pos +PCI_PRI_STATUS , &status); -return (control &PCI_PRI_TLP_OFF ) ? true : false; +return (status &PCI_PRI_TLP_OFF ) ? true : false; }/*
Greg KH
maintainerPATCH 27/82 iommu/amd: Add workaround for event log erratum
In reply to Greg KH3.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joerg Roedel <[email protected]>
commit 3d06fca8d2aa3543030e40b95f1d62f9f5a03540 upstream.
Due to a recent erratum it can happen that the head pointer of the event-log is updated before the actual event-log entry is written. This patch implements the recommended workaround.
--- drivers/iommu/amd_iommu.c | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-)
drivers/iommu/amd_iommu.c +23 -6
@@ -450,12 +450,27 @@ static void dump_command(unsigned long pstatic void iommu_print_event (struct amd_iommu *iommu,void *__evt) { -u32 *event = __evt; -int type = (event[1 ] >>EVENT_TYPE_SHIFT ) &EVENT_TYPE_MASK ; -int devid = (event[0 ] >>EVENT_DEVID_SHIFT ) &EVENT_DEVID_MASK ; -int domid = (event[1 ] >>EVENT_DOMID_SHIFT ) &EVENT_DOMID_MASK ; -int flags = (event[1 ] >>EVENT_FLAGS_SHIFT ) &EVENT_FLAGS_MASK ; -u64 address = (u64)(((u64 )event[3 ]) <<32 ) | event[2 ]; +int type, devid, domid, flags; +volatile u32 *event = __evt; +int count =0 ; +u64 address; + +retry: + type = (event[1 ] >>EVENT_TYPE_SHIFT ) &EVENT_TYPE_MASK ; + devid = (event[0 ] >>EVENT_DEVID_SHIFT ) &EVENT_DEVID_MASK ; + domid = (event[1 ] >>EVENT_DOMID_SHIFT ) &EVENT_DOMID_MASK ; + flags = (event[1 ] >>EVENT_FLAGS_SHIFT ) &EVENT_FLAGS_MASK ; + address = (u64)(((u64 )event[3 ]) <<32 ) | event[2 ]; + +if (type ==0 ) { +/* Did we hit the erratum? */ +if (++count ==LOOP_TIMEOUT ) { +pr_err ("AMD-Vi: No event written to event log\n" ); +return ; + } +udelay (1 ); + goto retry; + }printk (KERN_ERR "AMD-Vi: Event logged [" );
@@ -508,6 +523,8 @@ static void iommu_print_event(struct amddefault :printk (KERN_ERR "UNKNOWN type=0x%02x]\n" , type); } + +memset (__evt,0 ,4 *sizeof (u32)); }static void iommu_poll_events (struct amd_iommu *iommu)
Greg KH
maintainerPATCH 28/82 drm/radeon: fix XFX quirk
In reply to Greg KH3.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alex Deucher <[email protected]>
commit 1ebf169ad4dc68f18cc0dab35163b0f324fc6c41 upstream.
Only override the ddc bus if the connector doesn't have a valid one. The existing code overrode the ddc bus for all connectors even if it had ddc bus.
Fixes ddc on another XFX card with the same pci ids that was broken by the quirk overwriting the correct ddc bus.
--- drivers/gpu/drm/radeon/radeon_atombios.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/radeon/radeon_atombios.c +3 -1
@@ -444,7 +444,9 @@ static bool radeon_atom_apply_quirks(str*/ if ((dev->pdev->device ==0x9498 ) && (dev->pdev->subsystem_vendor ==0x1682 ) && - (dev->pdev->subsystem_device ==0x2452 )) { + (dev->pdev->subsystem_device ==0x2452 ) && + (i2c_bus->valid == false) && + !(supported_device & (ATOM_DEVICE_TV_SUPPORT |ATOM_DEVICE_CV_SUPPORT ))) {struct radeon_device *rdev = dev->dev_private; *i2c_bus =radeon_lookup_i2c_gpio (rdev,0x93 ); }
Greg KH
maintainerPATCH 29/82 drm/radeon: fix typo in trinity tiling setup
In reply to Greg KH3.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alex Deucher <[email protected]>
commit 1f73cca799d29df80de3e8f1f1c488485467577a upstream.
Using the wrong union.
--- drivers/gpu/drm/radeon/ni.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/radeon/ni.c +1 -1
@@ -865,7 +865,7 @@ static void cayman_gpu_init(struct radeo/* num banks is 8 on all fusion asics. 0 = 4, 1 = 8, 2 = 16 */ if (rdev->flags &RADEON_IS_IGP ) - rdev->config.evergreen.tile_config |=1 <<4 ; + rdev->config.cayman.tile_config |=1 <<4 ;else rdev->config.cayman.tile_config |= ((mc_arb_ramcfg &NOOFBANK_MASK ) >>NOOFBANK_SHIFT ) <<4 ;
Greg KH
maintainerPATCH 30/82 drm/i915: properly handle interlaced bit for sdvo dtd conversion
In reply to Greg KH3.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daniel Vetter <[email protected]>
commit 59d92bfa5f0cdf57f82f5181b0ad6af75c3fdf41 upstream.
We've simply ignored this, which isn't too great. With this, interlaced 1080i works on my HDMI screen connected through sdvo. For no apparent reason anything else still doesn't work as it should.
While at it, give these magic numbers in the dtd proper names and add a comment that they match with EDID detailed timings.
v2: Actually use the right bit for interlaced.
--- drivers/gpu/drm/i915/intel_sdvo.c | 12 ++++++++---- drivers/gpu/drm/i915/intel_sdvo_regs.h | 5 +++++ 2 files changed, 13 insertions(+), 4 deletions(-)
drivers/gpu/drm/i915/intel_sdvo.c +8 -4
@@ -769,10 +769,12 @@ static void intel_sdvo_get_dtd_from_mode ((v_sync_len &0x30 ) >>4 ); dtd->part2.dtd_flags =0x18 ; +if (mode->flags &DRM_MODE_FLAG_INTERLACE ) + dtd->part2.dtd_flags |=DTD_FLAG_INTERLACE ;if (mode->flags &DRM_MODE_FLAG_PHSYNC ) - dtd->part2.dtd_flags |=0x2 ; + dtd->part2.dtd_flags |=DTD_FLAG_HSYNC_POSITIVE ;if (mode->flags &DRM_MODE_FLAG_PVSYNC ) - dtd->part2.dtd_flags |=0x4 ; + dtd->part2.dtd_flags |=DTD_FLAG_VSYNC_POSITIVE ; dtd->part2.sdvo_flags =0 ; dtd->part2.v_sync_off_high = v_sync_offset &0xc0 ;
@@ -806,9 +808,11 @@ static void intel_sdvo_get_mode_from_dtd mode->clock = dtd->part1.clock *10 ; mode->flags &= ~(DRM_MODE_FLAG_PHSYNC |DRM_MODE_FLAG_PVSYNC ); -if (dtd->part2.dtd_flags &0x2 ) +if (dtd->part2.dtd_flags &DTD_FLAG_INTERLACE ) + mode->flags |=DRM_MODE_FLAG_INTERLACE ; +if (dtd->part2.dtd_flags &DTD_FLAG_HSYNC_POSITIVE ) mode->flags |=DRM_MODE_FLAG_PHSYNC ; -if (dtd->part2.dtd_flags &0x4 ) +if (dtd->part2.dtd_flags &DTD_FLAG_VSYNC_POSITIVE ) mode->flags |=DRM_MODE_FLAG_PVSYNC ; }
drivers/gpu/drm/i915/intel_sdvo_regs.h +5 -0
@@ -61,6 +61,11 @@ struct intel_sdvo_caps {u16 output_flags; } __attribute__((packed)); +/* Note: SDVO detailed timing flags match EDID misc flags. */ +#define DTD_FLAG_HSYNC_POSITIVE (1 << 1) +#define DTD_FLAG_VSYNC_POSITIVE (1 << 2) +#define DTD_FLAG_INTERLACE (1 << 7) +/** This matches the EDID DTD structure, more or less */ struct intel_sdvo_dtd { struct {
Greg KH
maintainerPATCH 31/82 drm/i915: Adding TV Out Missing modes.
In reply to Greg KH3.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rodrigo Vivi <[email protected]>
commit 9589919fb3d269d4202a112b197468c7db1f97a3 upstream.
These 2 modes were removed by mistake during a clean up. So, now it is time to add them back. For further info about supported mode and standard timing table please check:
VOL_3_display_registers_updated.pdf at intellinuxgraphics.org.
Note that this regression has been introduce in
commit 55a6713b3f30a5024056027e9dbf03ac8f13bfc9
Author: Rodrigo Vivi <[email protected]> Date: Thu Dec 15 14:47:33 2011 -0200
drm/i915: Removing TV Out modes.
and this commit partially reverts it by re-adding the wrongly removed modes.
[danvet: Pimped commit message to cite the commit that introduced this regression.]
--- drivers/gpu/drm/i915/intel_tv.c | 48 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+)
drivers/gpu/drm/i915/intel_tv.c +48 -0
@@ -674,6 +674,54 @@ static const struct tv_mode tv_modes[] = .filter_table = filter_table, }, { + .name = "480p", + .clock = 107520, + .refresh = 59940, + .oversample = TV_OVERSAMPLE_4X, + .component_only = 1, + + .hsync_end = 64, .hblank_end = 122, + .hblank_start = 842, .htotal = 857, + + .progressive = true, .trilevel_sync = false, + + .vsync_start_f1 = 12, .vsync_start_f2 = 12, + .vsync_len = 12, + + .veq_ena = false, + + .vi_end_f1 = 44, .vi_end_f2 = 44, + .nbr_end = 479, + + .burst_ena = false, + + .filter_table = filter_table, + }, + { + .name = "576p", + .clock = 107520, + .refresh = 50000, + .oversample = TV_OVERSAMPLE_4X, + .component_only = 1, + + .hsync_end = 64, .hblank_end = 139, + .hblank_start = 859, .htotal = 863, + + .progressive = true, .trilevel_sync = false, + + .vsync_start_f1 = 10, .vsync_start_f2 = 10, + .vsync_len = 10, + + .veq_ena = false, + + .vi_end_f1 = 48, .vi_end_f2 = 48, + .nbr_end = 575, + + .burst_ena = false, + + .filter_table = filter_table, + }, + { .name = "720p@60Hz", .clock = 148800, .refresh = 60000,
Greg KH
maintainerPATCH 32/82 drm/i915: wait for a vblank to pass after tv detect
In reply to Greg KH3.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daniel Vetter <[email protected]>
commit bf2125e2f7e931b50a6c76ba0435ba001409ccbf upstream.
Otherwise the hw will get confused and result in a black screen.
This regression has been most likely introduce in
commit 974b93315b2213b74a42a87e8a9d4fc8c0dbe90c
Author: Chris Wilson <[email protected]> Date: Sun Sep 5 00:44:20 2010 +0100
drm/i915/tv: Poll for DAC state change
That commit replace the first msleep(20) with a busy-loop, but failed to keep the 2nd msleep around. Later on we've replaced all these msleep(20) by proper vblanks.
For reference also see the commit in xf86-video-intel:
commit 1142be53eb8d2ee8a9b60ace5d49f0ba27332275
Author: Jesse Barnes <[email protected]> Date: Mon Jun 9 08:52:59 2008 -0700
Fix TV programming: add vblank wait after TV_CTL writes
Fxies FDO bug #14000; we need to wait for vblank after
writing TV_CTL or following "DPMS on" calls may not actually enable the output.
v2: As suggested by Chris Wilson, add a small comment to ensure that no one accidentally removes this vblank wait again - there really seems to be no sane explanation for why we need it, but it is required.
Launchpad: https://bugs.launchpad.net/ubuntu/+source/xserver-xorg-video-intel/+bug/763688
--- drivers/gpu/drm/i915/intel_tv.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/gpu/drm/i915/intel_tv.c +5 -0
@@ -1233,6 +1233,11 @@ intel_tv_detect_type(struct intel_tv *inI915_WRITE (TV_DAC , save_tv_dac & ~TVDAC_STATE_CHG_EN );I915_WRITE (TV_CTL , save_tv_ctl); +POSTING_READ (TV_CTL ); + +/* For unknown reasons the hw barfs if we don't do this vblank wait. */ +intel_wait_for_vblank (intel_tv->base.base.dev, +to_intel_crtc (intel_tv->base.base.crtc)->pipe);/* Restore interrupt config */ if (connector->polled &DRM_CONNECTOR_POLL_HPD ) {
Greg KH
maintainerPATCH 33/82 drm/i915: no lvds quirk for HP t5740e Thin Client
In reply to Greg KH3.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jan-Benedict Glaw <[email protected]>
commit 3347111999870c37eab1b969e90af9fdaf0334ba upstream.
This box has DisplayPort and VGA, but no LVDS. Product specs are at
http://h10010.www1.hp.com/wwpc/us/en/sm/WF25a/12454-12454-321959-338927-3640406-4282707.html?dnr=1
and dmidecode output can be found at http://www.getslash.de/bug_attachments/dmidecode-t5740e.txt
--- drivers/gpu/drm/i915/intel_lvds.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/gpu/drm/i915/intel_lvds.c +8 -0
@@ -747,6 +747,14 @@ static const struct dmi_system_id intel_ }, { .callback = intel_no_lvds_dmi_callback, + .ident = "Hewlett-Packard HP t5740e Thin Client", + .matches = { +DMI_MATCH (DMI_BOARD_VENDOR ,"Hewlett-Packard" ), + DMI_MATCH(DMI_PRODUCT_NAME, "HP t5740e Thin Client"), + }, + }, + { + .callback = intel_no_lvds_dmi_callback, .ident = "Hewlett-Packard t5745", .matches = { DMI_MATCH(DMI_BOARD_VENDOR, "Hewlett-Packard"),
Greg KH
maintainerPATCH 34/82 kbuild: install kernel-page-flags.h
In reply to Greg KH3.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ulrich Drepper <[email protected]>
commit 9295b7a07c859a42346221b5839be0ae612333b0 upstream.
Programs using /proc/kpageflags need to know about the various flags. The <linux/kernel-page-flags.h> provides them and the comments in the file indicate that it is supposed to be used by user-level code. But the file is not installed.
Install the headers and mark the unstable flags as out-of-bounds. The page-type tool is also adjusted to not duplicate the definitions
--- include/linux/Kbuild | 1 + include/linux/kernel-page-flags.h | 4 ++++ tools/vm/page-types.c | 28 +--------------------------- 3 files changed, 6 insertions(+), 27 deletions(-)
include/linux/Kbuild +1 -0
@@ -227,6 +227,7 @@ header-y += kd.h header-y += kdev_t.h header-y += kernel.h header-y += kernelcapi.h +header-y += kernel-page-flags.h header-y += keyboard.h header-y += keyctl.h header-y += l2tp.h
include/linux/kernel-page-flags.h +4 -0
@@ -32,6 +32,8 @@#define KPF_KSM 21#define KPF_THP 22 +#ifdef __KERNEL__ +/* kernel hacking assistances * WARNING: subject to change, never rely on them! */
@@ -44,4 +46,6 @@#define KPF_ARCH 38#define KPF_UNCACHED 39 +#endif /* __KERNEL__ */ +#endif /* LINUX_KERNEL_PAGE_FLAGS_H */
tools/vm/page-types.c +1 -27
@@ -35,6 +35,7 @@#include <sys/mount.h> #include <sys/statfs.h> #include "../../include/linux/magic.h" +#include "../../include/linux/kernel-page-flags.h" #ifndef MAX_PATH
@@ -73,33 +74,6 @@#define KPF_BYTES 8#define PROC_KPAGEFLAGS "/proc/kpageflags" -/* copied from kpageflags_read() */ -#define KPF_LOCKED 0 -#define KPF_ERROR 1 -#define KPF_REFERENCED 2 -#define KPF_UPTODATE 3 -#define KPF_DIRTY 4 -#define KPF_LRU 5 -#define KPF_ACTIVE 6 -#define KPF_SLAB 7 -#define KPF_WRITEBACK 8 -#define KPF_RECLAIM 9 -#define KPF_BUDDY 10 - -/* [11-20] new additions in 2.6.31 */ -#define KPF_MMAP 11 -#define KPF_ANON 12 -#define KPF_SWAPCACHE 13 -#define KPF_SWAPBACKED 14 -#define KPF_COMPOUND_HEAD 15 -#define KPF_COMPOUND_TAIL 16 -#define KPF_HUGE 17 -#define KPF_UNEVICTABLE 18 -#define KPF_HWPOISON 19 -#define KPF_NOPAGE 20 -#define KPF_KSM 21 -#define KPF_THP 22 -/* [32-] kernel hacking assistances */ #define KPF_RESERVED 32#define KPF_MLOCKED 33
Greg KH
maintainerPATCH 35/82 mm: fix vma_resv_map() NULL pointer
In reply to Greg KH3.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Hansen <[email protected]>
commit 4523e1458566a0e8ecfaff90f380dd23acc44d27 upstream.
hugetlb_reserve_pages() can be used for either normal file-backed hugetlbfs mappings, or MAP_HUGETLB. In the MAP_HUGETLB, semi-anonymous mode, there is not a VMA around. The new call to resv_map_put() assumed that there was, and resulted in a NULL pointer dereference:
BUG: unable to handle kernel NULL pointer dereference at 0000000000000030
IP: vma_resv_map+0x9/0x30
PGD 141453067 PUD 1421e1067 PMD 0
Oops: 0000 [#1] PREEMPT SMP
...
Pid: 14006, comm: trinity-child6 Not tainted 3.4.0+ #36
RIP: vma_resv_map+0x9/0x30
...
Process trinity-child6 (pid: 14006, threadinfo ffff8801414e0000, task ffff8801414f26b0)
Call Trace:
resv_map_put+0xe/0x40
hugetlb_reserve_pages+0xa6/0x1d0
hugetlb_file_setup+0x102/0x2c0
newseg+0x115/0x360
ipcget+0x1ce/0x310
sys_shmget+0x5a/0x60
system_call_fastpath+0x16/0x1bThis was reported by Dave Jones, but was reproducible with the libhugetlbfs test cases, so shame on me for not running them in the first place.
With this, the oops is gone, and the output of libhugetlbfs's run_tests.py is identical to plain 3.4 again.
[ Marked for stable, since this was introduced by commit c50ac050811d
("hugetlb: fix resv_map leak in error path") which was also marked for stable ]
--- mm/hugetlb.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
mm/hugetlb.c +2 -1
@@ -3035,7 +3035,8 @@ int hugetlb_reserve_pages(struct inode *region_add (&inode->i_mapping->private_list, from, to);return 0 ; out_err: -resv_map_put (vma); +if (vma) +resv_map_put (vma);return ret; }
Greg KH
maintainerPATCH 36/82 ALSA: usb-audio: fix rate_list memory leak
In reply to Greg KH3.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Clemens Ladisch <[email protected]>
commit 5cd5d7c44990658df6ab49f6253c39617c53b03d upstream.
The array of sample rates is reallocated every time when opening the PCM device, but was freed only once when unplugging the device.
--- sound/usb/pcm.c | 3 +++ 1 file changed, 3 insertions(+)
sound/usb/pcm.c +3 -0
@@ -699,6 +699,9 @@ static int snd_usb_pcm_check_knot(structint count =0 , needs_knot =0 ;int err; +kfree (subs->rate_list.list); + subs->rate_list.list =NULL ; +list_for_each_entry (fp, &subs->fmt_list, list) {if (fp->rates &SNDRV_PCM_RATE_CONTINUOUS )return 0 ;
Greg KH
maintainerPATCH 37/82 slub: fix a memory leak in get_partial_node()
In reply to Greg KH3.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joonsoo Kim <[email protected]>
commit 02d7633fa567be7bf55a993b79d2a31b95ce2227 upstream.
In the case which is below,
1. acquire slab for cpu partial list
2. free object to it by remote cpu
3. page->freelist = t
then memory leak is occurred.
Change acquire_slab() not to zap freelist when it works for cpu partial list. I think it is a sufficient solution for fixing a memory leak.
Below is output of 'slabinfo -r kmalloc-256'
when './perf stat -r 30 hackbench 50 process 4000 > /dev/null' is done.
***Vanilla***
Sizes (bytes) Slabs Debug Memory
------------------------------------------------------------------------
Object : 256 Total : 468 Sanity Checks : Off Total: 3833856 SlabObj: 256 Full : 111 Redzoning : Off Used : 2004992 SlabSiz: 8192 Partial: 302 Poisoning : Off Loss : 1828864 Loss : 0 CpuSlab: 55 Tracking : Off Lalig: 0 Align : 8 Objects: 32 Tracing : Off Lpadd: 0
***Patched***
Sizes (bytes) Slabs Debug Memory
------------------------------------------------------------------------
Object : 256 Total : 300 Sanity Checks : Off Total: 2457600 SlabObj: 256 Full : 204 Redzoning : Off Used : 2348800 SlabSiz: 8192 Partial: 33 Poisoning : Off Loss : 108800 Loss : 0 CpuSlab: 63 Tracking : Off Lalig: 0 Align : 8 Objects: 32 Tracing : Off Lpadd: 0
Total and loss number is the impact of this patch.
--- mm/slub.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
mm/slub.c +6 -3
@@ -1514,15 +1514,19 @@ static inline void *acquire_slab(struct freelist = page->freelist; counters = page->counters; new.counters = counters; -if (mode) +if (mode) { new.inuse = page->objects; + new.freelist =NULL ; + }else { + new.freelist = freelist; + }VM_BUG_ON (new.frozen); new.frozen =1 ; }while (!__cmpxchg_double_slab (s, page, freelist, counters, -NULL , new.counters, + new.freelist, new.counters,"lock and freeze" ));remove_partial (n, page);
@@ -1564,7 +1568,6 @@ static void *get_partial_node(struct kme object = t; available = page->objects - page->inuse; }else { - page->freelist = t; available =put_cpu_partial (s, page,0 );stat (s,CPU_PARTIAL_NODE ); }
Greg KH
maintainerPATCH 38/82 vfs: umount_tree() might be called on subtree that had never made it
In reply to Greg KH3.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Al Viro <[email protected]>
commit 63d37a84ab6004c235314ffd7a76c5eb28c2fae0 upstream.
__mnt_make_shortterm() in there undoes the effect of __mnt_make_longterm() we'd done back when we set ->mnt_ns non-NULL; it should not be done to vfsmounts that had never gone through commit_tree() and friends. Kudos to lczerner for catching that one...
--- fs/namespace.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/namespace.c +2 -1
@@ -1073,8 +1073,9 @@ void umount_tree(struct mount *mnt, intlist_del_init (&p->mnt_expire);list_del_init (&p->mnt_list);__touch_mnt_namespace (p->mnt_ns); +if (p->mnt_ns) +__mnt_make_shortterm (p); p->mnt_ns =NULL ; -__mnt_make_shortterm (p);list_del_init (&p->mnt_child);if (mnt_has_parent (p)) { p->mnt_parent->mnt_ghosts++;
Greg KH
maintainerPATCH 39/82 vfs: increment iversion when a file is truncated
In reply to Greg KH3.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dmitry Kasatkin <[email protected]>
commit 799243a389bde0de10fa21ca1ca453d2fe538b85 upstream.
When a file is truncated with truncate()/ftruncate() and then closed, iversion is not updated. This patch uses ATTR_SIZE flag as an indication to increment iversion.
Mimi said:
On fput(), i_version is used to detect and flag files that have changed and need to be re-measured in the IMA measurement policy. When a file is truncated with truncate()/ftruncate() and then closed, i_version is not updated. As a result, although the file has changed, it will not be re-measured and added to the IMA measurement list on subsequent access.
--- fs/attr.c | 5 +++++ 1 file changed, 5 insertions(+)
fs/attr.c +5 -0
@@ -176,6 +176,11 @@ int notify_change(struct dentry * dentryreturn -EPERM ; } +if ((ia_valid &ATTR_SIZE ) &&IS_I_VERSION (inode)) { +if (attr->ia_size != inode->i_size) +inode_inc_iversion (inode); + } +if ((ia_valid &ATTR_MODE )) {umode_t amode = attr->ia_mode;/* Flag setting protected by i_mutex */
Greg KH
maintainerPATCH 40/82 fec_mpc52xx: fix timestamp filtering
In reply to Greg KH3.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stephan Gatzka <[email protected]>
commit 9ca3cc6f3026946ba655e863ca2096339e667639 upstream.
skb_defer_rx_timestamp was called with a freshly allocated skb but must be called with rskb instead.
--- drivers/net/ethernet/freescale/fec_mpc52xx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/freescale/fec_mpc52xx.c +1 -1
@@ -437,7 +437,7 @@ static irqreturn_t mpc52xx_fec_rx_interr length = status &BCOM_FEC_RX_BD_LEN_MASK ;skb_put (rskb, length -4 );/* length without CRC32 */ rskb->protocol =eth_type_trans (rskb, dev); -if (!skb_defer_rx_timestamp (skb)) +if (!skb_defer_rx_timestamp (rskb))netif_rx (rskb);spin_lock (&priv->lock);
Greg KH
maintainerPATCH 41/82 x86, x32, ptrace: Remove PTRACE_ARCH_PRCTL for x32
In reply to Greg KH3.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: "H.J. Lu" <[email protected]>
commit bad1a753d4d4deb09d4bc0bac1dd4fc3298502e9 upstream.
When I added x32 ptrace to 3.4 kernel, I also include PTRACE_ARCH_PRCTL support for x32 GDB For ARCH_GET_FS/GS, it takes a pointer to int64. But at user level, ARCH_GET_FS/GS takes a pointer to int32. So I have to add x32 ptrace to glibc to handle it with a temporary int64 passed to kernel and copy it back to GDB as int32. Roland suggested that PTRACE_ARCH_PRCTL is obsolete and x32 GDB should use fs_base and gs_base fields of user_regs_struct instead.
Accordingly, remove PTRACE_ARCH_PRCTL completely from the x32 code to avoid possible memory overrun when pointer to int32 is passed to kernel.
--- arch/x86/kernel/ptrace.c | 6 ------ 1 file changed, 6 deletions(-)
arch/x86/kernel/ptrace.c +0 -6
@@ -1211,12 +1211,6 @@ static long x32_arch_ptrace(struct task_0 ,sizeof (struct user_i387_struct ), datap); -/* normal 64bit interface to access TLS data. -Works just like arch_prctl, except that the arguments -are reversed. */ -case PTRACE_ARCH_PRCTL : -return do_arch_prctl (child, data, addr); -default :return compat_ptrace_request (child, request, addr, data); }
Greg KH
maintainerPATCH 42/82 x86: Reset the debug_stack update counter
In reply to Greg KH3.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Steven Rostedt <[email protected]>
commit c0525a6972d3f1fb83058ef503e183475d6e4e26 upstream.
When an NMI goes off and it sees that it preempted the debug stack, to keep the debug stack safe, it changes the IDT to point to one that does not modify the stack on breakpoint (to allow breakpoints in NMIs).
But the variable that gets set to know to undo it on exit never gets cleared on exit. Thus every NMI will reset it on exit the first time it is done even if it does not need to be reset.
[ Added H. Peter Anvin's suggestion to use this_cpu_read/write ]
--- arch/x86/kernel/nmi.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
arch/x86/kernel/nmi.c +4 -2
@@ -491,14 +491,16 @@ static inline void nmi_nesting_preproces*/ if (unlikely (is_debug_stack (regs->sp))) {debug_stack_set_zero (); -__get_cpu_var (update_debug_stack) =1 ; +this_cpu_write (update_debug_stack,1 ); } }static inline void nmi_nesting_postprocess (void ) { -if (unlikely (__get_cpu_var (update_debug_stack))) +if (unlikely (this_cpu_read (update_debug_stack))) {debug_stack_reset (); +this_cpu_write (update_debug_stack,0 ); + } }#endif
Greg KH
maintainerPATCH 43/82 mtd: nand: fix scan_read_raw_oob
In reply to Greg KH3.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dmitry Maluka <[email protected]>
commit 34a5704d91d6f8376a4c0a0143a1dd3eb3ccb37e upstream.
It seems there is a bug in scan_read_raw_oob() in nand_bbt.c which should cause wrong functioning of NAND_BBT_SCANALLPAGES option.
Artem: the patch did not apply and I had to amend it a bit.
--- drivers/mtd/nand/nand_bbt.c | 1 + 1 file changed, 1 insertion(+)
drivers/mtd/nand/nand_bbt.c +1 -0
@@ -324,6 +324,7 @@ static int scan_read_raw_oob(struct mtd_ buf += mtd->oobsize + mtd->writesize; len -= mtd->writesize; + offs += mtd->writesize; }return 0 ; }
Greg KH
maintainerPATCH 44/82 mtd: of_parts: fix breakage in Kconfig
In reply to Greg KH3.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Frank Svendsboe <[email protected]>
commit 2e929d001e85126d9267de373d4b76014789661d upstream.
MTD_OF_PARTS and the default setting is not working due to using 'Y' instead of 'y', introduced in commit d6137badeff1ef64b4e0092ec249ebdeaeb3ff37. This made our board, and possibly other boards using DTS defined partitions and not having CONFIG_MTD_OF_PARTS=y defined in the defconfig, fail to mount root.
--- drivers/mtd/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/Kconfig +1 -1
@@ -128,7 +128,7 @@ config MTD_AFS_PARTS config MTD_OF_PARTS tristate "OpenFirmware partitioning information support" - default Y + default y depends on OF help This provides a partition parsing function which derives
Greg KH
maintainerPATCH 45/82 mtd: block2mtd: fix recursive call of mtd_writev
In reply to Greg KH3.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gabor Juhos <[email protected]>
commit 2e24e32e2759348c9290404abad4f729f791bfad upstream.
The 'mtd_writev' interface calls the function assigned to the '_write' field of a given mtd device if that is not NULL. The block2mtd driver sets the '_writev' field to the 'mtd_writev' function itself and thus causes a endless loop.
This is caused by 1dbebd32562b3c2caeca35960e5cb00bfcc12900 (mtd: harmonize mtd_writev usage).
Remove the assignment from the block2mtd driver to fix the issue.
--- drivers/mtd/devices/block2mtd.c | 1 - 1 file changed, 1 deletion(-)
drivers/mtd/devices/block2mtd.c +0 -1
@@ -271,7 +271,6 @@ static struct block2mtd_dev *add_device( dev->mtd.flags =MTD_CAP_RAM ; dev->mtd._erase = block2mtd_erase; dev->mtd._write = block2mtd_write; - dev->mtd._writev = mtd_writev; dev->mtd._sync = block2mtd_sync; dev->mtd._read = block2mtd_read; dev->mtd.priv = dev;
Greg KH
maintainerPATCH 46/82 mtd: mxc_nand: move ecc strengh setup before nand_scan_tail
In reply to Greg KH3.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sascha Hauer <[email protected]>
commit 4a43faf54e9173b6acce37cf7f053fc9515a2cdf upstream.
Since commit 6a918bade9dab40aaef80559bd1169c69e8d69cb, the mxc_nand driver fails with:
Driver must set ecc.strength when using hardware ECC
This is because nand_scan_tail checks for correct ecc strength settings, so we must set them up before nand_scan_tail.
--- drivers/mtd/nand/mxc_nand.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/mtd/nand/mxc_nand.c +6 -6
@@ -1219,12 +1219,6 @@ static int __init mxcnd_probe(struct plaif (nfc_is_v21 () && mtd->writesize ==4096 ) this->ecc.layout = &nandv2_hw_eccoob_4k; -/* second phase scan */ -if (nand_scan_tail (mtd)) { - err = -ENXIO ; - goto escan; - } -if (this->ecc.mode ==NAND_ECC_HW ) {if (nfc_is_v1 ()) this->ecc.strength =1 ;
@@ -1232,6 +1226,12 @@ static int __init mxcnd_probe(struct pla this->ecc.strength = (host->eccsize ==4 ) ?4 :8 ; } +/* second phase scan */ +if (nand_scan_tail (mtd)) { + err = -ENXIO ; + goto escan; + } +/* Register the partitions */ mtd_device_parse_register (mtd, part_probes,NULL , pdata->parts, pdata->nr_parts);
Greg KH
maintainerPATCH 47/82 drm/radeon: fix regression in UMS CS ioctl
In reply to Greg KH3.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alex Deucher <[email protected]>
commit 9b00147d9f2ba137ce74b66b768a8312be0b6781 upstream.
radeon_cs_parser_init is called by both the legacy UMS CS ioctl and the KMS CS ioctl. Protect KMS specific pieces of the code by checking that rdev is not NULL.
--- drivers/gpu/drm/radeon/radeon_cs.c | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-)
drivers/gpu/drm/radeon/radeon_cs.c +17 -14
@@ -158,6 +158,7 @@ static int radeon_cs_sync_rings(struct rreturn 0 ; } +/* XXX: note that this is called from the legacy UMS CS ioctl as well */ int radeon_cs_parser_init (struct radeon_cs_parser *p,void *data) {struct drm_radeon_cs *cs = data;
@@ -252,23 +253,25 @@ int radeon_cs_parser_init(struct radeon_ } } -if ((p->cs_flags &RADEON_CS_USE_VM ) && - !p->rdev->vm_manager.enabled) { -DRM_ERROR ("VM not active on asic!\n" ); -return -EINVAL ; - } +/* these are KMS only */ +if (p->rdev) { +if ((p->cs_flags &RADEON_CS_USE_VM ) && + !p->rdev->vm_manager.enabled) { +DRM_ERROR ("VM not active on asic!\n" ); +return -EINVAL ; + } + +/* we only support VM on SI+ */ +if ((p->rdev->family >=CHIP_TAHITI ) && + ((p->cs_flags &RADEON_CS_USE_VM ) ==0 )) { +DRM_ERROR ("VM required on SI+!\n" ); +return -EINVAL ; + } -/* we only support VM on SI+ */ -if ((p->rdev->family >=CHIP_TAHITI ) && - ((p->cs_flags &RADEON_CS_USE_VM ) ==0 )) { -DRM_ERROR ("VM required on SI+!\n" ); -return -EINVAL ; +if (radeon_cs_get_ring (p, ring, priority)) +return -EINVAL ; } -if (radeon_cs_get_ring (p, ring, priority)) -return -EINVAL ; - -/* deal with non-vm */ if ((p->chunk_ib_idx != -1) && ((p->cs_flags & RADEON_CS_USE_VM) == 0) &&
Greg KH
maintainerPATCH 48/82 drm/radeon: fix bank information in tiling config
In reply to Greg KH3.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alex Deucher <[email protected]>
commit 29d654067a98c1cb8874c774e5fd799a038af8a6 upstream.
While there are cards with more than 8 mem banks, the max number of banks from a tiling perspective is 8, so cap the tiling config at 8 banks.
Fixes:
https://bugs.freedesktop.org/show_bug.cgi?id=43448
--- drivers/gpu/drm/radeon/evergreen.c | 9 ++++++--- drivers/gpu/drm/radeon/ni.c | 9 ++++++--- drivers/gpu/drm/radeon/rv770.c | 8 ++++++-- 3 files changed, 18 insertions(+), 8 deletions(-)
drivers/gpu/drm/radeon/evergreen.c +6 -3
@@ -2136,9 +2136,12 @@ static void evergreen_gpu_init(struct ra/* num banks is 8 on all fusion asics. 0 = 4, 1 = 8, 2 = 16 */ if (rdev->flags &RADEON_IS_IGP ) rdev->config.evergreen.tile_config |=1 <<4 ; -else - rdev->config.evergreen.tile_config |= - ((mc_arb_ramcfg &NOOFBANK_MASK ) >>NOOFBANK_SHIFT ) <<4 ; +else { +if ((mc_arb_ramcfg &NOOFBANK_MASK ) >>NOOFBANK_SHIFT ) + rdev->config.evergreen.tile_config |=1 <<4 ; +else + rdev->config.evergreen.tile_config |=0 <<4 ; + } rdev->config.evergreen.tile_config |= ((mc_arb_ramcfg &BURSTLENGTH_MASK ) >>BURSTLENGTH_SHIFT ) <<8 ; rdev->config.evergreen.tile_config |=
drivers/gpu/drm/radeon/ni.c +6 -3
@@ -866,9 +866,12 @@ static void cayman_gpu_init(struct radeo/* num banks is 8 on all fusion asics. 0 = 4, 1 = 8, 2 = 16 */ if (rdev->flags &RADEON_IS_IGP ) rdev->config.cayman.tile_config |=1 <<4 ; -else - rdev->config.cayman.tile_config |= - ((mc_arb_ramcfg &NOOFBANK_MASK ) >>NOOFBANK_SHIFT ) <<4 ; +else { +if ((mc_arb_ramcfg &NOOFBANK_MASK ) >>NOOFBANK_SHIFT ) + rdev->config.cayman.tile_config |=1 <<4 ; +else + rdev->config.cayman.tile_config |=0 <<4 ; + } rdev->config.cayman.tile_config |= ((gb_addr_config &PIPE_INTERLEAVE_SIZE_MASK ) >>PIPE_INTERLEAVE_SIZE_SHIFT ) <<8 ; rdev->config.cayman.tile_config |=
drivers/gpu/drm/radeon/rv770.c +6 -2
@@ -689,8 +689,12 @@ static void rv770_gpu_init(struct radeonif (rdev->family ==CHIP_RV770 ) gb_tiling_config |=BANK_TILING (1 ); -else - gb_tiling_config |=BANK_TILING ((mc_arb_ramcfg &NOOFBANK_MASK ) >>NOOFBANK_SHIFT ); +else { +if ((mc_arb_ramcfg &NOOFBANK_MASK ) >>NOOFBANK_SHIFT ) + gb_tiling_config |=BANK_TILING (1 ); +else + gb_tiling_config |=BANK_TILING (0 ); + } rdev->config.rv770.tiling_nbanks =4 << ((gb_tiling_config >>4 ) &0x3 ); gb_tiling_config |=GROUP_SIZE ((mc_arb_ramcfg &BURSTLENGTH_MASK ) >>BURSTLENGTH_SHIFT );if ((mc_arb_ramcfg &BURSTLENGTH_MASK ) >>BURSTLENGTH_SHIFT )
Greg KH
maintainerPATCH 49/82 drm/radeon: properly program gart on rv740, juniper, cypress, barts, hemlock
In reply to Greg KH3.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alex Deucher <[email protected]>
commit 0b8c30bc4943137a4a36b9cb059b1cc684f5d702 upstream.
Need to program an additional VM register. This doesn't not currently cause any problems, but allows us to program the proper backend map in a subsequent patch which should improve performance on these asics.
--- drivers/gpu/drm/radeon/evergreen.c | 5 +++++ drivers/gpu/drm/radeon/evergreend.h | 1 + drivers/gpu/drm/radeon/rv770.c | 2 ++ drivers/gpu/drm/radeon/rv770d.h | 1 + 4 files changed, 9 insertions(+)
drivers/gpu/drm/radeon/evergreen.c +5 -0
@@ -1029,6 +1029,11 @@ int evergreen_pcie_gart_enable(struct raWREG32 (MC_VM_MD_L1_TLB0_CNTL , tmp);WREG32 (MC_VM_MD_L1_TLB1_CNTL , tmp);WREG32 (MC_VM_MD_L1_TLB2_CNTL , tmp); +if ((rdev->family ==CHIP_JUNIPER ) || + (rdev->family ==CHIP_CYPRESS ) || + (rdev->family ==CHIP_HEMLOCK ) || + (rdev->family ==CHIP_BARTS )) +WREG32 (MC_VM_MD_L1_TLB3_CNTL , tmp); }WREG32 (MC_VM_MB_L1_TLB0_CNTL , tmp);WREG32 (MC_VM_MB_L1_TLB1_CNTL , tmp);
drivers/gpu/drm/radeon/evergreend.h +1 -0
@@ -232,6 +232,7 @@#define MC_VM_MD_L1_TLB0_CNTL 0x2654#define MC_VM_MD_L1_TLB1_CNTL 0x2658#define MC_VM_MD_L1_TLB2_CNTL 0x265C +#define MC_VM_MD_L1_TLB3_CNTL 0x2698#define FUS_MC_VM_MD_L1_TLB0_CNTL 0x265C#define FUS_MC_VM_MD_L1_TLB1_CNTL 0x2660
drivers/gpu/drm/radeon/rv770.c +2 -0
@@ -151,6 +151,8 @@ int rv770_pcie_gart_enable(struct radeonWREG32 (MC_VM_MD_L1_TLB0_CNTL , tmp);WREG32 (MC_VM_MD_L1_TLB1_CNTL , tmp);WREG32 (MC_VM_MD_L1_TLB2_CNTL , tmp); +if (rdev->family ==CHIP_RV740 ) +WREG32 (MC_VM_MD_L1_TLB3_CNTL , tmp);WREG32 (MC_VM_MB_L1_TLB0_CNTL , tmp);WREG32 (MC_VM_MB_L1_TLB1_CNTL , tmp);WREG32 (MC_VM_MB_L1_TLB2_CNTL , tmp);
drivers/gpu/drm/radeon/rv770d.h +1 -0
@@ -174,6 +174,7 @@#define MC_VM_MD_L1_TLB0_CNTL 0x2654#define MC_VM_MD_L1_TLB1_CNTL 0x2658#define MC_VM_MD_L1_TLB2_CNTL 0x265C +#define MC_VM_MD_L1_TLB3_CNTL 0x2698#define MC_VM_SYSTEM_APERTURE_DEFAULT_ADDR 0x203C#define MC_VM_SYSTEM_APERTURE_HIGH_ADDR 0x2038#define MC_VM_SYSTEM_APERTURE_LOW_ADDR 0x2034
Greg KH
maintainerPATCH 50/82 drm/radeon: fix HD6790, HD6570 backend programming
In reply to Greg KH3.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jerome Glisse <[email protected]>
commit 95c4b23ec4e2fa5604df229ddf134e31d7b3b378 upstream.
Without this bit sets we get broken rendering and lockups.
fglrx sets this bit.
Bugs that should be fixed by this patch :
https://bugs.freedesktop.org/show_bug.cgi?id=49792
https://bugzilla.kernel.org/show_bug.cgi?id=43207
https://bugs.freedesktop.org/show_bug.cgi?id=39282
--- drivers/gpu/drm/radeon/evergreen.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/radeon/evergreen.c +2 -2
@@ -2178,9 +2178,9 @@ static void evergreen_gpu_init(struct raWREG32 (CC_SYS_RB_BACKEND_DISABLE , rb);WREG32 (GC_USER_RB_BACKEND_DISABLE , rb);WREG32 (CC_GC_SHADER_PIPE_CONFIG , sp); - } + } - grbm_gfx_index |=SE_BROADCAST_WRITES ; + grbm_gfx_index =INSTANCE_BROADCAST_WRITES |SE_BROADCAST_WRITES ;WREG32 (GRBM_GFX_INDEX , grbm_gfx_index);WREG32 (RLC_GFX_INDEX , grbm_gfx_index);
Greg KH
maintainerPATCH 51/82 drm/ttm: Fix spinlock imbalance
In reply to Greg KH3.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Hellstrom <[email protected]>
commit a8ff3ee211fccf708e1911bbc096625453ebf759 upstream.
This imbalance may cause hangs when TTM is trying to swap out a buffer that is already on the delayed delete list.
--- drivers/gpu/drm/ttm/ttm_bo.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/ttm/ttm_bo.c +1 -0
@@ -1821,6 +1821,7 @@ static int ttm_bo_swapout(struct ttm_memspin_unlock (&glob->lru_lock); (void )ttm_bo_cleanup_refs (bo, false, false, false);kref_put (&bo->list_kref, ttm_bo_release_list); +spin_lock (&glob->lru_lock);continue ; }
Greg KH
maintainerPATCH 52/82 drm/vmwgfx: Fix nasty write past alloced memory area
In reply to Greg KH3.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Hellstrom <[email protected]>
commit 0824db38e515644f8d1bfd64adbd7cb2c6ea7c62 upstream.
--- drivers/gpu/drm/vmwgfx/vmwgfx_gmr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/vmwgfx/vmwgfx_gmr.c +1 -1
@@ -66,7 +66,7 @@ static int vmw_gmr2_bind(struct vmw_priv cmd +=sizeof (remap_cmd) /sizeof (uint32);for (i =0 ; i < num_pages; ++i) { -if (VMW_PPN_SIZE >4 ) +if (VMW_PPN_SIZE <=4 ) *cmd =page_to_pfn (*pages++);else *((uint64_t *)cmd) =page_to_pfn (*pages++);
Greg KH
maintainerPATCH 53/82 asix: allow full size 8021Q frames to be received
In reply to Greg KH3.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit 9dae31009b1a00d926c6fe032d5a88099620adc3 ]
asix driver drops 8021Q full size frames because it doesn't take into account VLAN header size.
Tested on AX88772 adapter.
--- drivers/net/usb/asix.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/usb/asix.c +2 -1
@@ -35,6 +35,7 @@#include <linux/crc32.h> #include <linux/usb/usbnet.h> #include <linux/slab.h> +#include <linux/if_vlan.h> #define DRIVER_VERSION "22-Dec-2011"#define DRIVER_NAME "asix"
@@ -321,7 +322,7 @@ static int asix_rx_fixup(struct usbnet *return 0 ; } -if ((size > dev->net->mtu +ETH_HLEN ) || +if ((size > dev->net->mtu +ETH_HLEN +VLAN_HLEN ) || (size + offset > skb->len)) {netdev_err (dev->net,"asix_rx_fixup() Bad RX Length %d\n" , size);
Greg KH
maintainerPATCH 54/82 ipv4: fix the rcu race between free_fib_info and ip_route_output_slow
In reply to Greg KH3.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yanmin Zhang <[email protected]>
[ Upstream commit e49cc0da7283088c5e03d475ffe2fdcb24a6d5b1 ]
We hit a kernel OOPS.
<3>[23898.789643] BUG: sleeping function called from invalid context at /data/buildbot/workdir/ics/hardware/intel/linux-2.6/arch/x86/mm/fault.c:1103 <3>[23898.862215] in_atomic(): 0, irqs_disabled(): 0, pid: 10526, name: Thread-6683 <4>[23898.967805] HSU serial 0000:00:05.1: 0000:00:05.2:HSU serial prevented me to suspend... <4>[23899.258526] Pid: 10526, comm: Thread-6683 Tainted: G W 3.0.8-137685-ge7742f9 #1 <4>[23899.357404] HSU serial 0000:00:05.1: 0000:00:05.2:HSU serial prevented me to suspend... <4>[23899.904225] Call Trace: <4>[23899.989209] [<c1227f50>] ? pgtable_bad+0x130/0x130 <4>[23900.000416] [<c1238c2a>] __might_sleep+0x10a/0x110 <4>[23900.007357] [<c1228021>] do_page_fault+0xd1/0x3c0 <4>[23900.013764] [<c18e9ba9>] ? restore_all+0xf/0xf <4>[23900.024024] [<c17c007b>] ? napi_complete+0x8b/0x690 <4>[23900.029297] [<c1227f50>] ? pgtable_bad+0x130/0x130 <4>[23900.123739] [<c1227f50>] ? pgtable_bad+0x130/0x130 <4>[23900.128955] [<c18ea0c3>] error_code+0x5f/0x64 <4>[23900.133466] [<c1227f50>] ? pgtable_bad+0x130/0x130 <4>[23900.138450] [<c17f6298>] ? __ip_route_output_key+0x698/0x7c0 <4>[23900.144312] [<c17f5f8d>] ? __ip_route_output_key+0x38d/0x7c0 <4>[23900.150730] [<c17f63df>] ip_route_output_flow+0x1f/0x60 <4>[23900.156261] [<c181de58>] ip4_datagram_connect+0x188/0x2b0 <4>[23900.161960] [<c18e981f>] ? _raw_spin_unlock_bh+0x1f/0x30 <4>[23900.167834] [<c18298d6>] inet_dgram_connect+0x36/0x80 <4>[23900.173224] [<c14f9e88>] ? _copy_from_user+0x48/0x140 <4>[23900.178817] [<c17ab9da>] sys_connect+0x9a/0xd0 <4>[23900.183538] [<c132e93c>] ? alloc_file+0xdc/0x240 <4>[23900.189111] [<c123925d>] ? sub_preempt_count+0x3d/0x50
Function free_fib_info resets nexthop_nh->nh_dev to NULL before releasing fi. Other cpu might be accessing fi. Fixing it by delaying the releasing.
With the patch, we ran MTBF testing on Android mobile for 12 hours and didn't trigger the issue.
Thank Eric for very detailed review/checking the issue.
--- net/ipv4/fib_semantics.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
net/ipv4/fib_semantics.c +6 -6
@@ -145,6 +145,12 @@ static void free_fib_info_rcu(struct rcu { struct fib_info *fi = container_of(head, struct fib_info, rcu); +change_nexthops (fi) { +if (nexthop_nh->nh_dev) +dev_put (nexthop_nh->nh_dev); + }endfor_nexthops (fi); + +release_net (fi->fib_net);if (fi->fib_metrics != (u32 *) dst_default_metrics)kfree (fi->fib_metrics);kfree (fi);
@@ -156,13 +162,7 @@ void free_fib_info(struct fib_info *fi)pr_warn ("Freeing alive fib_info %p\n" , fi);return ; } -change_nexthops (fi) { -if (nexthop_nh->nh_dev) -dev_put (nexthop_nh->nh_dev); - nexthop_nh->nh_dev =NULL ; - }endfor_nexthops (fi); fib_info_cnt--; -release_net (fi->fib_net);call_rcu (&fi->rcu, free_fib_info_rcu); }
Greg KH
maintainerPATCH 55/82 ipv6: fix incorrect ipsec fragment
In reply to Greg KH3.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gao feng <[email protected]>
[ Upstream commit 0c1833797a5a6ec23ea9261d979aa18078720b74 ]
Since commit ad0081e43a
"ipv6: Fragment locally generated tunnel-mode IPSec6 packets as needed" the fragment of packets is incorrect.
because tunnel mode needs IPsec headers and trailer for all fragments, while on transport mode it is sufficient to add the headers to the first fragment and the trailer to the last.
so modify mtu and maxfraglen base on ipsec mode and if fragment is first or last.
with my test,it work well(every fragment's size is the mtu) and does not trigger slow fragment path.
Changes from v1:
though optimization, mtu_prev and maxfraglen_prev can be delete. replace xfrm mode codes with dst_entry's new frag DST_XFRM_TUNNEL. add fuction ip6_append_data_mtu to make codes clearer.
--- include/net/dst.h | 1 net/ipv6/ip6_output.c | 68 ++++++++++++++++++++++++++++++++++++------------- net/xfrm/xfrm_policy.c | 3 ++ 3 files changed, 54 insertions(+), 18 deletions(-)
include/net/dst.h +1 -0
@@ -60,6 +60,7 @@ struct dst_entry {#define DST_NOCOUNT 0x0020#define DST_NOPEER 0x0040#define DST_FAKE_RTABLE 0x0080 +#define DST_XFRM_TUNNEL 0x0100short error;short obsolete;
net/ipv6/ip6_output.c +50 -18
109 lines not on this page · raw message
net/xfrm/xfrm_policy.c +3 -0
@@ -1919,6 +1919,9 @@ no_transform: } ok:xfrm_pols_put (pols, drop_pols); +if (dst && dst->xfrm && + dst->xfrm->props.mode ==XFRM_MODE_TUNNEL ) + dst->flags |=DST_XFRM_TUNNEL ;return dst; nopol:
Greg KH
maintainerPATCH 56/82 l2tp: fix oops in L2TP IP sockets for connect() AF_UNSPEC case
In reply to Greg KH3.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: James Chapman <[email protected]>
[ Upstream commit c51ce49735c183ef2592db70f918ee698716276b ]
An application may call connect() to disconnect a socket using an address with family AF_UNSPEC. The L2TP IP sockets were not handling this case when the socket is not bound and an attempt to connect() using AF_UNSPEC in such cases would result in an oops. This patch addresses the problem by protecting the sk_prot->disconnect() call against trying to unhash the socket before it is bound.
The patch also adds more checks that the sockaddr supplied to bind() and connect() calls is valid.
RIP: 0010:[<ffffffff82e133b0>] [<ffffffff82e133b0>] inet_unhash+0x50/0xd0 RSP: 0018:ffff88001989be28 EFLAGS: 00010293 Stack: ffff8800407a8000 0000000000000000 ffff88001989be78 ffffffff82e3a249 ffffffff82e3a050 ffff88001989bec8 ffff88001989be88 ffff8800407a8000 0000000000000010 ffff88001989bec8 ffff88001989bea8 ffffffff82e42639 Call Trace: [<ffffffff82e3a249>] udp_disconnect+0x1f9/0x290 [<ffffffff82e42639>] inet_dgram_connect+0x29/0x80 [<ffffffff82d012fc>] sys_connect+0x9c/0x100
--- net/l2tp/l2tp_ip.c | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-)
net/l2tp/l2tp_ip.c +24 -6
@@ -251,9 +251,16 @@ static int l2tp_ip_bind(struct sock *sk, {struct inet_sock *inet =inet_sk (sk);struct sockaddr_l2tpip *addr = (struct sockaddr_l2tpip *) uaddr; -int ret = -EINVAL ; +int ret;int chk_addr_ret; +if (!sock_flag (sk,SOCK_ZAPPED )) +return -EINVAL ; +if (addr_len <sizeof (struct sockaddr_l2tpip )) +return -EINVAL ; +if (addr->l2tp_family !=AF_INET ) +return -EINVAL ; + ret = -EADDRINUSE ;read_lock_bh (&l2tp_ip_lock);if (__l2tp_ip_bind_lookup (&init_net, addr->l2tp_addr.s_addr, sk->sk_bound_dev_if, addr->l2tp_conn_id))
@@ -284,6 +291,8 @@ static int l2tp_ip_bind(struct sock *sk,sk_del_node_init (sk);write_unlock_bh (&l2tp_ip_lock); ret =0 ; +sock_reset_flag (sk,SOCK_ZAPPED ); + out:release_sock (sk);
@@ -304,13 +313,14 @@ static int l2tp_ip_connect(struct sock *__be32 saddr;int oif, rc; - rc = -EINVAL ; +if (sock_flag (sk,SOCK_ZAPPED ))/* Must bind first - autobinding does not work */ +return -EINVAL ; +if (addr_len <sizeof (*lsa)) - goto out; +return -EINVAL ; - rc = -EAFNOSUPPORT ;if (lsa->l2tp_family !=AF_INET ) - goto out; +return -EAFNOSUPPORT ;lock_sock (sk);
@@ -364,6 +374,14 @@ out:return rc; } +static int l2tp_ip_disconnect (struct sock *sk,int flags) +{ +if (sock_flag (sk,SOCK_ZAPPED )) +return 0 ; + +return udp_disconnect (sk, flags); +} +static int l2tp_ip_getname (struct socket *sock,struct sockaddr *uaddr,int *uaddr_len,int peer) {
@@ -599,7 +617,7 @@ static struct proto l2tp_ip_prot = { .close = l2tp_ip_close, .bind = l2tp_ip_bind, .connect = l2tp_ip_connect, - .disconnect = udp_disconnect, + .disconnect = l2tp_ip_disconnect, .ioctl = udp_ioctl, .destroy = l2tp_ip_destroy_sock, .setsockopt = ip_setsockopt,
Greg KH
maintainerPATCH 57/82 skb: avoid unnecessary reallocations in __skb_cow
In reply to Greg KH3.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Felix Fietkau <[email protected]>
[ Upstream commit 617c8c11236716dcbda877e764b7bf37c6fd8063 ]
At the beginning of __skb_cow, headroom gets set to a minimum of NET_SKB_PAD. This causes unnecessary reallocations if the buffer was not cloned and the headroom is just below NET_SKB_PAD, but still more than the amount requested by the caller.
This was showing up frequently in my tests on VLAN tx, where vlan_insert_tag calls skb_cow_head(skb, VLAN_HLEN).
Locally generated packets should have enough headroom, and for forward paths, we already have NET_SKB_PAD bytes of headroom, so we don't need to add any extra space here.
--- include/linux/skbuff.h | 2 -- 1 file changed, 2 deletions(-)
include/linux/skbuff.h +0 -2
@@ -1881,8 +1881,6 @@ static inline int __skb_cow(struct sk_bu {int delta =0 ; -if (headroom <NET_SKB_PAD ) - headroom =NET_SKB_PAD ;if (headroom >skb_headroom (skb)) delta = headroom -skb_headroom (skb);
Greg KH
maintainerPATCH 58/82 xfrm: take net hdr len into account for esp payload size calculation
In reply to Greg KH3.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Benjamin Poirier <[email protected]>
[ Upstream commit 91657eafb64b4cb53ec3a2fbc4afc3497f735788 ]
Corrects the function that determines the esp payload size. The calculations done in esp{4,6}_get_mtu() lead to overlength frames in transport mode for certain mtu values and suboptimal frames for others.
According to what is done, mainly in esp{,6}_output() and tcp_mtu_to_mss(), net_header_len must be taken into account before doing the alignment calculation.
--- net/ipv4/esp4.c | 24 +++++++++--------------- net/ipv6/esp6.c | 18 +++++++----------- 2 files changed, 16 insertions(+), 26 deletions(-)
net/ipv4/esp4.c +9 -15
@@ -459,28 +459,22 @@ static u32 esp4_get_mtu(struct xfrm_statstruct esp_data *esp = x->data;u32 blksize =ALIGN (crypto_aead_blocksize (esp->aead),4 );u32 align =max_t (u32, blksize, esp->padlen); -u32 rem; - - mtu -= x->props.header_len +crypto_aead_authsize (esp->aead); - rem = mtu & (align -1 ); - mtu &= ~(align -1 ); +unsigned int net_adj;switch (x->props.mode) { -case XFRM_MODE_TUNNEL : -break ; -default :case XFRM_MODE_TRANSPORT : -/* The worst case */ - mtu -= blksize -4 ; - mtu +=min_t (u32, blksize -4 , rem); -break ;case XFRM_MODE_BEET : -/* The worst case. */ - mtu +=min_t (u32,IPV4_BEET_PHMAXLEN , rem); + net_adj =sizeof (struct iphdr ); +break ; +case XFRM_MODE_TUNNEL : + net_adj =0 ;break ; +default : +BUG (); } -return mtu -2 ; +return ((mtu - x->props.header_len -crypto_aead_authsize (esp->aead) - + net_adj) & ~(align -1 )) + (net_adj -2 ); }static void esp4_err (struct sk_buff *skb,u32 info)
net/ipv6/esp6.c +7 -11
@@ -411,19 +411,15 @@ static u32 esp6_get_mtu(struct xfrm_statstruct esp_data *esp = x->data;u32 blksize =ALIGN (crypto_aead_blocksize (esp->aead),4 );u32 align =max_t (u32, blksize, esp->padlen); -u32 rem; +unsigned int net_adj; - mtu -= x->props.header_len +crypto_aead_authsize (esp->aead); - rem = mtu & (align -1 ); - mtu &= ~(align -1 ); +if (x->props.mode !=XFRM_MODE_TUNNEL ) + net_adj =sizeof (struct ipv6hdr ); +else + net_adj =0 ; -if (x->props.mode !=XFRM_MODE_TUNNEL ) { -u32 padsize = ((blksize -1 ) &7 ) +1 ; - mtu -= blksize - padsize; - mtu +=min_t (u32, blksize - padsize, rem); - } - -return mtu -2 ; +return ((mtu - x->props.header_len -crypto_aead_authsize (esp->aead) - + net_adj) & ~(align -1 )) + (net_adj -2 ); } static void esp6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
Greg KH
maintainerPATCH 59/82 ext4: fix potential NULL dereference in ext4_free_inodes_counts()
In reply to Greg KH3.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
commit bb3d132a24cd8bf5e7773b2d9f9baa58b07a7dae upstream.
The ext4_get_group_desc() function returns NULL on error, and ext4_free_inodes_count() function dereferences it without checking. There is a check on the next line, but it's too late.
--- fs/ext4/ialloc.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
fs/ext4/ialloc.c +6 -4
@@ -488,10 +488,12 @@ fallback_retry:for (i =0 ; i < ngroups; i++) { grp = (parent_group + i) % ngroups; desc =ext4_get_group_desc (sb, grp,NULL ); - grp_free =ext4_free_inodes_count (sb, desc); -if (desc && grp_free && grp_free >= avefreei) { - *group = grp; -return 0 ; +if (desc) { + grp_free =ext4_free_inodes_count (sb, desc); +if (grp_free && grp_free >= avefreei) { + *group = grp; +return 0 ; + } } }
Greg KH
maintainerPATCH 60/82 ext4: force ro mount if ext4_setup_super() fails
In reply to Greg KH3.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Sandeen <[email protected]>
commit 7e84b6216467b84cd332c8e567bf5aa113fd2f38 upstream.
If ext4_setup_super() fails i.e. due to a too-high revision, the error is logged in dmesg but the fs is not mounted RO as indicated.
Tested by:
# mkfs.ext4 -r 4 /dev/sdb6 # mount /dev/sdb6 /mnt/test # dmesg | grep "too high" [164919.759248] EXT4-fs (sdb6): revision level too high, forcing read-only mode # grep sdb6 /proc/mounts /dev/sdb6 /mnt/test2 ext4 rw,seclabel,relatime,data=ordered 0 0
--- fs/ext4/super.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/ext4/super.c +2 -1
@@ -3592,7 +3592,8 @@ no_journal: goto failed_mount4; } -ext4_setup_super (sb, es, sb->s_flags &MS_RDONLY ); +if (ext4_setup_super (sb, es, sb->s_flags &MS_RDONLY )) + sb->s_flags |=MS_RDONLY ;/* determine the minimum size of new large inodes, if present */ if (sbi->s_inode_size >EXT4_GOOD_OLD_INODE_SIZE ) {
Greg KH
maintainerPATCH 61/82 ext4: fix potential integer overflow in alloc_flex_gd()
In reply to Greg KH3.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Haogang Chen <[email protected]>
commit 967ac8af4475ce45474800709b12137aa7634c77 upstream.
In alloc_flex_gd(), when flexbg_size is large, kmalloc size would overflow and flex_gd->groups would point to a buffer smaller than expected, causing OOB accesses when it is used.
Note that in ext4_resize_fs(), flexbg_size is calculated using sbi->s_log_groups_per_flex, which is read from the disk and only bounded to [1, 31]. The patch returns NULL for too large flexbg_size.
--- fs/ext4/resize.c | 2 ++ 1 file changed, 2 insertions(+)
fs/ext4/resize.c +2 -0
@@ -161,6 +161,8 @@ static struct ext4_new_flex_group_data *if (flex_gd ==NULL ) goto out3; +if (flexbg_size >=UINT_MAX /sizeof (struct ext4_new_flex_group_data )) + goto out2; flex_gd->count = flexbg_size; flex_gd->groups = kmalloc(sizeof(struct ext4_new_group_data) *
Greg KH
maintainerPATCH 62/82 ext4: disallow hard-linked directory in ext4_lookup
In reply to Greg KH3.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andreas Dilger <[email protected]>
commit 7e936b737211e6b54e34b71a827e56b872e958d8 upstream.
A hard-linked directory to its parent can cause the VFS to deadlock, and is a sign of a corrupted file system. So detect this case in ext4_lookup(), before the rmdir() lockup scenario can take place.
--- fs/ext4/namei.c | 6 ++++++ 1 file changed, 6 insertions(+)
fs/ext4/namei.c +6 -0
@@ -1037,6 +1037,12 @@ static struct dentry *ext4_lookup(structEXT4_ERROR_INODE (dir,"bad inode number: %u" , ino);return ERR_PTR (-EIO ); } +if (unlikely (ino == dir->i_ino)) { +EXT4_ERROR_INODE (dir,"'%.*s' linked to parent dir" , + dentry->d_name.len, + dentry->d_name.name); +return ERR_PTR (-EIO ); + } inode =ext4_iget (dir->i_sb, ino);if (inode ==ERR_PTR (-ESTALE )) { EXT4_ERROR_INODE(dir,
Greg KH
maintainerPATCH 63/82 ext4: add missing save_error_info() to ext4_error()
In reply to Greg KH3.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Theodore Ts'o <[email protected]>
commit f3fc0210c0fc91900766c995f089c39170e68305 upstream.
The ext4_error() function is missing a call to save_error_info(). Since this is the function which marks the file system as containing an error, this oversight (which was introduced in 2.6.36) is quite significant, and should be backported to older stable kernels with high urgency.
--- fs/ext4/super.c | 1 + 1 file changed, 1 insertion(+)
fs/ext4/super.c +1 -0
@@ -497,6 +497,7 @@ void __ext4_error(struct super_block *sbprintk (KERN_CRIT "EXT4-fs error (device %s): %s:%d: comm %s: %pV\n" , sb->s_id, function, line, current->comm, &vaf);va_end (args); +save_error_info (sb, function, line);ext4_handle_error (sb); }
Greg KH
maintainerPATCH 64/82 ext4: dont trash state flags in EXT4_IOC_SETFLAGS
In reply to Greg KH3.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Theodore Ts'o <[email protected]>
commit 79906964a187c405db72a3abc60eb9b50d804fbc upstream.
In commit 353eb83c we removed i_state_flags with 64-bit longs, But when handling the EXT4_IOC_SETFLAGS ioctl, we replace i_flags directly, which trashes the state flags which are stored in the high 32-bits of i_flags on 64-bit platforms. So use the the ext4_{set,clear}_inode_flags() functions which use atomic bit manipulation functions instead.
--- fs/ext4/ioctl.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
fs/ext4/ioctl.c +9 -3
@@ -38,7 +38,7 @@ long ext4_ioctl(struct file *filp, unsighandle_t *handle =NULL ;int err, migrate =0 ;struct ext4_iloc iloc; -unsigned int oldflags; +unsigned int oldflags, mask, i;unsigned int jflag;if (!inode_owner_or_capable (inode))
@@ -115,8 +115,14 @@ long ext4_ioctl(struct file *filp, unsigif (err) goto flags_err; - flags = flags &EXT4_FL_USER_MODIFIABLE ; - flags |= oldflags & ~EXT4_FL_USER_MODIFIABLE ; +for (i =0 , mask =1 ; i <32 ; i++, mask <<=1 ) { +if (!(mask &EXT4_FL_USER_MODIFIABLE )) +continue ; +if (mask & flags) +ext4_set_inode_flag (inode, i); +else +ext4_clear_inode_flag (inode, i); + } ei->i_flags = flags;ext4_set_inode_flags (inode);
Greg KH
maintainerPATCH 65/82 ext4: add ext4_mb_unload_buddy in the error path
In reply to Greg KH3.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Salman Qazi <[email protected]>
commit 02b7831019ea4e7994968c84b5826fa8b248ffc8 upstream.
ext4_free_blocks fails to pair an ext4_mb_load_buddy with a matching ext4_mb_unload_buddy when it fails a memory allocation.
--- fs/ext4/mballoc.c | 1 + 1 file changed, 1 insertion(+)
fs/ext4/mballoc.c +1 -0
@@ -4636,6 +4636,7 @@ do_more:*/ new_entry =kmem_cache_alloc (ext4_free_data_cachep,GFP_NOFS );if (!new_entry) { +ext4_mb_unload_buddy (&e4b); err = -ENOMEM ; goto error_return; }
Greg KH
maintainerPATCH 66/82 ext4: remove mb_groups before tearing down the buddy_cache
In reply to Greg KH3.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Salman Qazi <[email protected]>
commit 95599968d19db175829fb580baa6b68939b320fb upstream.
We can't have references held on pages in the s_buddy_cache while we are trying to truncate its pages and put the inode. All the pages must be gone before we reach clear_inode. This can only be gauranteed if we can prevent new users from grabbing references to s_buddy_cache's pages.
The original bug can be reproduced and the bug fix can be verified by:
while true; do mount -t ext4 /dev/ram0 /export/hda3/ram0; \
umount /export/hda3/ram0; done &
while true; do cat /proc/fs/ext4/ram0/mb_groups; done
--- fs/ext4/mballoc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
fs/ext4/mballoc.c +3 -2
@@ -2517,6 +2517,9 @@ int ext4_mb_release(struct super_block *struct ext4_sb_info *sbi =EXT4_SB (sb);struct kmem_cache *cachep =get_groupinfo_cache (sb->s_blocksize_bits); +if (sbi->s_proc) +remove_proc_entry ("mb_groups" , sbi->s_proc); +if (sbi->s_group_info) {for (i =0 ; i < ngroups; i++) { grinfo =ext4_get_group_info (sb, i);
@@ -2564,8 +2567,6 @@ int ext4_mb_release(struct super_block * }free_percpu (sbi->s_locality_groups); -if (sbi->s_proc) -remove_proc_entry ("mb_groups" , sbi->s_proc);return 0 ; }
Greg KH
maintainerPATCH 67/82 radix-tree: fix contiguous iterator
In reply to Greg KH3.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Konstantin Khlebnikov <[email protected]>
commit fffaee365fded09f9ebf2db19066065fa54323c3 upstream.
This patch fixes bug in macro radix_tree_for_each_contig().
If radix_tree_next_slot() sees NULL in next slot it returns NULL, but following radix_tree_next_chunk() switches iterating into next chunk. As result iterating becomes non-contiguous and breaks vfs "splice" and all its users.
--- include/linux/radix-tree.h | 5 ++++- lib/radix-tree.c | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-)
include/linux/radix-tree.h +4 -1
@@ -368,8 +368,11 @@ radix_tree_next_slot(void **slot, struct iter->index++;if (likely (*slot))return slot; -if (flags &RADIX_TREE_ITER_CONTIG ) +if (flags &RADIX_TREE_ITER_CONTIG ) { +/* forbid switching to the next chunk */ + iter->next_index =0 ;break ; + } } }return NULL ;
lib/radix-tree.c +3 -0
@@ -673,6 +673,9 @@ void **radix_tree_next_chunk(struct radi* during iterating; it can be zero only at the beginning. * And we cannot overflow iter->next_index in a single step, * because RADIX_TREE_MAP_SHIFT < BITS_PER_LONG. +* +* This condition also used by radix_tree_next_slot() to stop +* contiguous iterating, and forbid swithing to the next chunk. */ index = iter->next_index;if (!index && iter->index)
Greg KH
maintainerPATCH 68/82 drm/radeon/audio: dont hardcode CRTC id
In reply to Greg KH3.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rafał Miłecki <[email protected]>
commit 0aecb5a4ba1ea4167f31d1790eec027f1e658f2d upstream.
This is based on info released by AMD, should allow using audio in much more cases.
--- drivers/gpu/drm/radeon/r600_audio.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/gpu/drm/radeon/r600_audio.c +3 -2
@@ -239,6 +239,7 @@ void r600_audio_set_clock(struct drm_encstruct radeon_device *rdev = dev->dev_private;struct radeon_encoder *radeon_encoder =to_radeon_encoder (encoder);struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv; +struct radeon_crtc *radeon_crtc =to_radeon_crtc (encoder->crtc);int base_rate =48000 ;switch (radeon_encoder->encoder_id) {
@@ -264,8 +265,8 @@ void r600_audio_set_clock(struct drm_encWREG32 (EVERGREEN_AUDIO_PLL1_DIV , clock *10 );WREG32 (EVERGREEN_AUDIO_PLL1_UNK ,0x00000071 ); -/* Some magic trigger or src sel? */ -WREG32_P (0x5ac ,0x01 , ~0x77 ); +/* Select DTO source */ +WREG32 (0x5ac , radeon_crtc->crtc_id); }else {switch (dig->dig_encoder) {case 0 :
Greg KH
maintainerPATCH 69/82 drm/radeon: fix vm deadlocks on cayman
In reply to Greg KH3.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christian König <[email protected]>
commit bb4091558228ff4a3e02328c931e683fc7f08722 upstream.
Locking mutex in different orders just screams for deadlocks, and some testing showed that it is actually quite easy to trigger them.
--- drivers/gpu/drm/radeon/radeon_gart.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-)
drivers/gpu/drm/radeon/radeon_gart.c +12 -7
@@ -478,12 +478,18 @@ int radeon_vm_bo_add(struct radeon_devicmutex_lock (&vm->mutex);if (last_pfn > vm->last_pfn) { -/* grow va space 32M by 32M */ -unsigned align = ((32 <<20 ) >>12 ) -1 ; +/* release mutex and lock in right order */ +mutex_unlock (&vm->mutex);radeon_mutex_lock (&rdev->cs_mutex); -radeon_vm_unbind_locked (rdev, vm); +mutex_lock (&vm->mutex); +/* and check again */ +if (last_pfn > vm->last_pfn) { +/* grow va space 32M by 32M */ +unsigned align = ((32 <<20 ) >>12 ) -1 ; +radeon_vm_unbind_locked (rdev, vm); + vm->last_pfn = (last_pfn + align) & ~align; + }radeon_mutex_unlock (&rdev->cs_mutex); - vm->last_pfn = (last_pfn + align) & ~align; } head = &vm->va; last_offset =0 ;
@@ -597,8 +603,8 @@ int radeon_vm_bo_rmv(struct radeon_devicif (bo_va ==NULL )return 0 ; -mutex_lock (&vm->mutex);radeon_mutex_lock (&rdev->cs_mutex); +mutex_lock (&vm->mutex);radeon_vm_bo_update_pte (rdev, vm, bo,NULL );radeon_mutex_unlock (&rdev->cs_mutex);list_del (&bo_va->vm_list);
@@ -643,9 +649,8 @@ void radeon_vm_fini(struct radeon_devicestruct radeon_bo_va *bo_va, *tmp;int r; -mutex_lock (&vm->mutex); -radeon_mutex_lock (&rdev->cs_mutex); +mutex_lock (&vm->mutex);radeon_vm_unbind_locked (rdev, vm);radeon_mutex_unlock (&rdev->cs_mutex);
Greg KH
maintainerPATCH 70/82 drm/radeon/kms: add new Trinity PCI ids
In reply to Greg KH3.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alex Deucher <[email protected]>
commit d430f7dbf7bd6aaaa40c0660b3204df8cf07b22b upstream.
--- drivers/gpu/drm/radeon/ni.c | 21 +++++++++++++++++---- include/drm/drm_pciids.h | 8 ++++++++ 2 files changed, 25 insertions(+), 4 deletions(-)
drivers/gpu/drm/radeon/ni.c +17 -4
@@ -657,15 +657,28 @@ static void cayman_gpu_init(struct radeo rdev->config.cayman.max_pipes_per_simd =4 ; rdev->config.cayman.max_tile_pipes =2 ;if ((rdev->pdev->device ==0x9900 ) || - (rdev->pdev->device ==0x9901 )) { + (rdev->pdev->device ==0x9901 ) || + (rdev->pdev->device ==0x9905 ) || + (rdev->pdev->device ==0x9906 ) || + (rdev->pdev->device ==0x9907 ) || + (rdev->pdev->device ==0x9908 ) || + (rdev->pdev->device ==0x9909 ) || + (rdev->pdev->device ==0x9910 ) || + (rdev->pdev->device ==0x9917 )) { rdev->config.cayman.max_simds_per_se =6 ; rdev->config.cayman.max_backends_per_se =2 ; }else if ((rdev->pdev->device ==0x9903 ) || - (rdev->pdev->device ==0x9904 )) { + (rdev->pdev->device ==0x9904 ) || + (rdev->pdev->device ==0x990A ) || + (rdev->pdev->device ==0x9913 ) || + (rdev->pdev->device ==0x9918 )) { rdev->config.cayman.max_simds_per_se =4 ; rdev->config.cayman.max_backends_per_se =2 ; - }else if ((rdev->pdev->device ==0x9990 ) || - (rdev->pdev->device ==0x9991 )) { + }else if ((rdev->pdev->device ==0x9919 ) || + (rdev->pdev->device ==0x9990 ) || + (rdev->pdev->device ==0x9991 ) || + (rdev->pdev->device ==0x9994 ) || + (rdev->pdev->device ==0x99A0 )) { rdev->config.cayman.max_simds_per_se =3 ; rdev->config.cayman.max_backends_per_se =1 ; }else {
include/drm/drm_pciids.h +8 -0
@@ -561,11 +561,19 @@ {0x1002, 0x9909, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_ARUBA|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ {0x1002, 0x990A, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_ARUBA|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ {0x1002, 0x990F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_ARUBA|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ + {0x1002, 0x9910, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_ARUBA|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ + {0x1002, 0x9913, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_ARUBA|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ + {0x1002, 0x9917, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_ARUBA|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ + {0x1002, 0x9918, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_ARUBA|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ + {0x1002, 0x9919, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_ARUBA|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ {0x1002, 0x9990, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_ARUBA|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ {0x1002, 0x9991, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_ARUBA|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ {0x1002, 0x9992, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_ARUBA|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ {0x1002, 0x9993, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_ARUBA|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ {0x1002, 0x9994, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_ARUBA|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ + {0x1002, 0x99A0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_ARUBA|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ + {0x1002, 0x99A2, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_ARUBA|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ + {0x1002, 0x99A4, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_ARUBA|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ {0, 0, 0} #define r128_PCI_IDS \
Greg KH
maintainerPATCH 71/82 drm/radeon/kms: add new Palm, Sumo PCI ids
In reply to Greg KH3.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alex Deucher <[email protected]>
commit 4a6991cc1fad514745b79181df3ace72d561e7aa upstream.
--- include/drm/drm_pciids.h | 2 ++ 1 file changed, 2 insertions(+)
include/drm/drm_pciids.h +2 -0
@@ -531,6 +531,7 @@ {0x1002, 0x9645, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_SUMO2|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ {0x1002, 0x9647, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_SUMO|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP|RADEON_IS_IGP},\ {0x1002, 0x9648, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_SUMO|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP|RADEON_IS_IGP},\ + {0x1002, 0x9649, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_SUMO|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP|RADEON_IS_IGP},\ {0x1002, 0x964a, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_SUMO|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ {0x1002, 0x964b, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_SUMO|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ {0x1002, 0x964c, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_SUMO|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \
@@ -550,6 +551,7 @@ {0x1002, 0x9807, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_PALM|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ {0x1002, 0x9808, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_PALM|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ {0x1002, 0x9809, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_PALM|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ + {0x1002, 0x980A, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_PALM|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ {0x1002, 0x9900, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_ARUBA|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ {0x1002, 0x9901, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_ARUBA|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ {0x1002, 0x9903, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_ARUBA|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \
Greg KH
maintainerPATCH 72/82 drm/radeon/kms: add new BTC PCI ids
In reply to Greg KH3.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alex Deucher <[email protected]>
commit a2bef8ce826dd1e787fd8ad9b6e0566ba59dab43 upstream.
--- include/drm/drm_pciids.h | 2 ++ 1 file changed, 2 insertions(+)
include/drm/drm_pciids.h +2 -0
@@ -181,6 +181,7 @@ {0x1002, 0x6747, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TURKS|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6748, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TURKS|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6749, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TURKS|RADEON_NEW_MEMMAP}, \ + {0x1002, 0x674A, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TURKS|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6750, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TURKS|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6751, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TURKS|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6758, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TURKS|RADEON_NEW_MEMMAP}, \
@@ -198,6 +199,7 @@ {0x1002, 0x6767, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CAICOS|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6768, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CAICOS|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6770, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CAICOS|RADEON_NEW_MEMMAP}, \ + {0x1002, 0x6771, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CAICOS|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6772, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CAICOS|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6778, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CAICOS|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6779, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CAICOS|RADEON_NEW_MEMMAP}, \
Greg KH
maintainerPATCH 73/82 drm/radeon/kms: add new SI PCI ids
In reply to Greg KH3.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alex Deucher <[email protected]>
commit 7aaa61b3476462b69f1ac7669fcca8d608ce3cb5 upstream.
--- include/drm/drm_pciids.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
include/drm/drm_pciids.h +3 -2
@@ -231,10 +231,11 @@ {0x1002, 0x6827, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6828, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6829, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|RADEON_NEW_MEMMAP}, \ + {0x1002, 0x682B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x682D, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x682F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ - {0x1002, 0x6830, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|RADEON_NEW_MEMMAP}, \ - {0x1002, 0x6831, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|RADEON_NEW_MEMMAP}, \ + {0x1002, 0x6830, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ + {0x1002, 0x6831, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6837, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6838, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6839, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|RADEON_NEW_MEMMAP}, \
Greg KH
maintainerPATCH 74/82 iommu/amd: Cache pdev pointer to root-bridge
In reply to Greg KH3.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joerg Roedel <[email protected]>
commit c1bf94ec1e12d76838ad485158aecf208ebd8fb9 upstream.
At some point pci_get_bus_and_slot started to enable interrupts. Since this function is used in the amd_iommu_resume path it will enable interrupts on resume which causes a warning. The fix will use a cached pointer to the root-bridge to re-enable the IOMMU in case the BIOS is broken.
--- drivers/iommu/amd_iommu_init.c | 13 +++++-------- drivers/iommu/amd_iommu_types.h | 3 +++ 2 files changed, 8 insertions(+), 8 deletions(-)
drivers/iommu/amd_iommu_init.c +5 -8
@@ -1029,6 +1029,9 @@ static int __init init_iommu_one(structif (!iommu->dev)return 1 ; + iommu->root_pdev =pci_get_bus_and_slot (iommu->dev->bus->number, +PCI_DEVFN (0 ,0 )); + iommu->cap_ptr = h->cap_ptr; iommu->pci_seg = h->pci_seg; iommu->mmio_phys = h->mmio_phys;
@@ -1323,20 +1326,16 @@ static void iommu_apply_resume_quirks(st {int i, j;u32 ioc_feature_control; -struct pci_dev *pdev =NULL ; +struct pci_dev *pdev = iommu->root_pdev;/* RD890 BIOSes may not have completely reconfigured the iommu */ -if (!is_rd890_iommu (iommu->dev)) +if (!is_rd890_iommu (iommu->dev) || !pdev)return ;/* * First, we need to ensure that the iommu is enabled. This is * controlled by a register in the northbridge */ - pdev =pci_get_bus_and_slot (iommu->dev->bus->number,PCI_DEVFN (0 ,0 )); - -if (!pdev) -return ;/* Select Northbridge indirect register 0x75 and enable writing */ pci_write_config_dword (pdev,0x60 ,0x75 | (1 <<7 ));
@@ -1346,8 +1345,6 @@ static void iommu_apply_resume_quirks(stif (!(ioc_feature_control &0x1 ))pci_write_config_dword (pdev,0x64 , ioc_feature_control |1 ); -pci_dev_put (pdev); -/* Restore the iommu BAR */ pci_write_config_dword (iommu->dev, iommu->cap_ptr +4 , iommu->stored_addr_lo);
drivers/iommu/amd_iommu_types.h +3 -0
@@ -481,6 +481,9 @@ struct amd_iommu {/* Pointer to PCI device of this IOMMU */ struct pci_dev *dev; +/* Cache pdev to root device for resume quirks */ +struct pci_dev *root_pdev; +/* physical address of MMIO space */ u64 mmio_phys;/* virtual address of MMIO space */
Greg KH
maintainerPATCH 75/82 iommu/amd: Fix deadlock in ppr-handling error path
In reply to Greg KH3.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joerg Roedel <[email protected]>
commit eee53537c476c947bf7faa1c916d2f5a0ae8ec93 upstream.
In the error path of the ppr_notifer it can happen that the iommu->lock is taken recursivly. This patch fixes the problem by releasing the iommu->lock before any notifier is invoked. This also requires to move the erratum workaround for the ppr-log (interrupt may be faster than data in the log) one function up.
--- drivers/iommu/amd_iommu.c | 73 ++++++++++++++++++++++++++++------------------ 1 file changed, 45 insertions(+), 28 deletions(-)
drivers/iommu/amd_iommu.c +45 -28
@@ -547,26 +547,12 @@ static void iommu_poll_events(struct amdspin_unlock_irqrestore (&iommu->lock, flags); } -static void iommu_handle_ppr_entry (struct amd_iommu *iommu,u32 head) +static void iommu_handle_ppr_entry (struct amd_iommu *iommu,u64 *raw) {struct amd_iommu_fault fault; -volatile u64 *raw; -int i;INC_STATS_COUNTER (pri_requests); - raw = (u64 *)(iommu->ppr_log + head); - -/* -* Hardware bug: Interrupt may arrive before the entry is written to -* memory. If this happens we need to wait for the entry to arrive. -*/ -for (i =0 ; i <LOOP_TIMEOUT ; ++i) { -if (PPR_REQ_TYPE (raw[0 ]) !=0 ) -break ; -udelay (1 ); - } -if (PPR_REQ_TYPE (raw[0 ]) !=PPR_REQ_FAULT ) {pr_err_ratelimited ("AMD-Vi: Unknown PPR request received\n" );return ;
@@ -578,12 +564,6 @@ static void iommu_handle_ppr_entry(struc fault.tag =PPR_TAG (raw[0 ]); fault.flags =PPR_FLAGS (raw[0 ]); -/* -* To detect the hardware bug we need to clear the entry -* to back to zero. -*/ - raw[0 ] = raw[1 ] =0 ; -atomic_notifier_call_chain (&ppr_notifier,0 , &fault); }
@@ -595,25 +575,62 @@ static void iommu_poll_ppr_log(struct amif (iommu->ppr_log ==NULL )return ; +/* enable ppr interrupts again */ +writel (MMIO_STATUS_PPR_INT_MASK , iommu->mmio_base +MMIO_STATUS_OFFSET ); +spin_lock_irqsave (&iommu->lock, flags); head =readl (iommu->mmio_base +MMIO_PPR_HEAD_OFFSET ); tail =readl (iommu->mmio_base +MMIO_PPR_TAIL_OFFSET );while (head != tail) { +volatile u64 *raw; +u64 entry[2 ]; +int i; + + raw = (u64 *)(iommu->ppr_log + head); + +/* +* Hardware bug: Interrupt may arrive before the entry is +* written to memory. If this happens we need to wait for the +* entry to arrive. +*/ +for (i =0 ; i <LOOP_TIMEOUT ; ++i) { +if (PPR_REQ_TYPE (raw[0 ]) !=0 ) +break ; +udelay (1 ); + } + +/* Avoid memcpy function-call overhead */ + entry[0 ] = raw[0 ]; + entry[1 ] = raw[1 ]; + +/* +* To detect the hardware bug we need to clear the entry +* back to zero. +*/ + raw[0 ] = raw[1 ] =0UL ; -/* Handle PPR entry */ -iommu_handle_ppr_entry (iommu, head); - -/* Update and refresh ring-buffer state*/ +/* Update head pointer of hardware ring-buffer */ head = (head +PPR_ENTRY_SIZE ) %PPR_LOG_SIZE ;writel (head, iommu->mmio_base +MMIO_PPR_HEAD_OFFSET ); + +/* +* Release iommu->lock because ppr-handling might need to +* re-aquire it +*/ +spin_unlock_irqrestore (&iommu->lock, flags); + +/* Handle PPR entry */ +iommu_handle_ppr_entry (iommu, entry); + +spin_lock_irqsave (&iommu->lock, flags); + +/* Refresh ring-buffer information */ + head =readl (iommu->mmio_base +MMIO_PPR_HEAD_OFFSET ); tail =readl (iommu->mmio_base +MMIO_PPR_TAIL_OFFSET ); } -/* enable ppr interrupts again */ -writel (MMIO_STATUS_PPR_INT_MASK , iommu->mmio_base +MMIO_STATUS_OFFSET ); -spin_unlock_irqrestore (&iommu->lock, flags); }
Greg KH
maintainerPATCH 76/82 ACPI battery: only refresh the sysfs files when pertinent information changes
In reply to Greg KH3.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andy Whitcroft <[email protected]>
commit c5971456964290da7e98222892797b71ef793e62 upstream.
We only need to regenerate the sysfs files when the capacity units change, avoid the update otherwise.
The origin of this issue is dates way back to 2.6.38:da8aeb92d4853f37e281f11fddf61f9c7d84c3cd
(ACPI / Battery: Update information on info notification and resume)
--- drivers/acpi/battery.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/acpi/battery.c +9 -1
@@ -643,11 +643,19 @@ static int acpi_battery_update(struct acstatic void acpi_battery_refresh (struct acpi_battery *battery) { +int power_unit; +if (!battery->bat.dev)return ; + power_unit = battery->power_unit; +acpi_battery_get_info (battery); -/* The battery may have changed its reporting units. */ + +if (power_unit == battery->power_unit) +return ; + +/* The battery has changed its reporting units. */ sysfs_remove_battery (battery);sysfs_add_battery (battery); }
Greg KH
maintainerPATCH 77/82 vfs: Fix /proc/<tid>/fdinfo/<fd> file handling
In reply to Greg KH3.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Torvalds <[email protected]>
commit 0640113be25d283e0ff77a9f041e1242182387f0 upstream.
Cyrill Gorcunov reports that I broke the fdinfo files with commit 30a08bf2d31d ("proc: move fd symlink i_mode calculations into tid_fd_revalidate()"), and he's quite right.
The tid_fd_revalidate() function is not just used for the <tid>/fd symlinks, it's also used for the <tid>/fdinfo/<fd> files, and the permission model for those are different.
So do the dynamic symlink permission handling just for symlinks, making the fdinfo files once more appear as the proper regular files they are.
Of course, Al Viro argued (probably correctly) that we shouldn't do the symlink permission games at all, and make the symlinks always just be the normal 'lrwxrwxrwx'. That would have avoided this issue too, but since somebody noticed that the permissions had changed (which was the reason for that original commit 30a08bf2d31d in the first place), people do apparently use this feature.
[ Basically, you can use the symlink permission data as a cheap "fdinfo"
replacement, since you see whether the file is open for reading and/or writing by just looking at st_mode of the symlink. So the feature does make sense, even if the pain it has caused means we probably shouldn't have done it to begin with. ]
--- fs/proc/base.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-)
fs/proc/base.c +10 -7
@@ -1803,7 +1803,7 @@ static int tid_fd_revalidate(struct dentrcu_read_lock (); file =fcheck_files (files, fd);if (file) { -unsigned i_mode, f_mode = file->f_mode; +unsigned f_mode = file->f_mode;rcu_read_unlock ();put_files_struct (files);
@@ -1819,12 +1819,14 @@ static int tid_fd_revalidate(struct dent inode->i_gid =0 ; } - i_mode =S_IFLNK ; -if (f_mode &FMODE_READ ) - i_mode |=S_IRUSR |S_IXUSR ; -if (f_mode &FMODE_WRITE ) - i_mode |=S_IWUSR |S_IXUSR ; - inode->i_mode = i_mode; +if (S_ISLNK (inode->i_mode)) { +unsigned i_mode =S_IFLNK ; +if (f_mode &FMODE_READ ) + i_mode |=S_IRUSR |S_IXUSR ; +if (f_mode &FMODE_WRITE ) + i_mode |=S_IWUSR |S_IXUSR ; + inode->i_mode = i_mode; + }security_task_to_inode (task, inode);put_task_struct (task);
@@ -1859,6 +1861,7 @@ static struct dentry *proc_fd_instantiat ei =PROC_I (inode); ei->fd = fd; + inode->i_mode =S_IFLNK ; inode->i_op = &proc_pid_link_inode_operations; inode->i_size =64 ; ei->op.proc_get_link = proc_fd_link;
Greg KH
maintainerPATCH 78/82 md: raid1/raid10: fix problem with merge_bvec_fn
In reply to Greg KH3.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: NeilBrown <[email protected]>
commit aba336bd1d46d6b0404b06f6915ed76150739057 upstream.
The new merge_bvec_fn which calls the corresponding function in subsidiary devices requires that mddev->merge_check_needed be set if any child has a merge_bvec_fn.
However were were only setting that when a device was hot-added, not when a device was present from the start.
This bug was introduced in 3.4 so patch is suitable for 3.4.y kernels. However that are conflicts in raid10.c so a separate patch will be needed for 3.4.y.
--- drivers/md/raid1.c | 4 ++++ drivers/md/raid10.c | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-)
drivers/md/raid1.c +4 -0
@@ -2548,6 +2548,7 @@ static struct r1conf *setup_conf(struct err = -EINVAL ;spin_lock_init (&conf->device_lock);rdev_for_each (rdev, mddev) { +struct request_queue *q;int disk_idx = rdev->raid_disk;if (disk_idx >= mddev->raid_disks || disk_idx <0 )
@@ -2560,6 +2561,9 @@ static struct r1conf *setup_conf(structif (disk->rdev) goto abort; disk->rdev = rdev; + q =bdev_get_queue (rdev->bdev); +if (q->merge_bvec_fn) + mddev->merge_check_needed =1 ; disk->head_position =0 ; }
drivers/md/raid10.c +4 -1
@@ -3311,7 +3311,7 @@ static int run(struct mddev *mddev) (conf->raid_disks / conf->near_copies));rdev_for_each (rdev, mddev) { - +struct request_queue *q; disk_idx = rdev->raid_disk;if (disk_idx >= conf->raid_disks || disk_idx <0 )
@@ -3327,6 +3327,9 @@ static int run(struct mddev *mddev) goto out_free_conf; disk->rdev = rdev; } + q =bdev_get_queue (rdev->bdev); +if (q->merge_bvec_fn) + mddev->merge_check_needed =1 ;disk_stack_limits (mddev->gendisk, rdev->bdev, rdev->data_offset <<9 );
Greg KH
maintainerPATCH 79/82 wl1251: fix oops on early interrupt
In reply to Greg KH3.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Grazvydas Ignotas <[email protected]>
commit f380f2c4a12e913356bd49f8790ec1063c4fe9f8 upstream.
This driver disables interrupt just after requesting it and enables it later, after interface is up. However currently there is a time window between request_irq() and disable_irq() where if interrupt arrives, the driver oopses because it's not yet ready to process it. This can be reproduced by inserting the module, associating and removing the module multiple times.
Eliminate this race by setting IRQF_NOAUTOEN flag before request_irq().
--- drivers/net/wireless/wl1251/sdio.c | 2 +- drivers/net/wireless/wl1251/spi.c | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-)
drivers/net/wireless/wl1251/sdio.c +1 -1
@@ -260,6 +260,7 @@ static int wl1251_sdio_probe(struct sdio }if (wl->irq) { +irq_set_status_flags (wl->irq,IRQ_NOAUTOEN ); ret =request_irq (wl->irq, wl1251_line_irq,0 ,"wl1251" , wl);if (ret <0 ) {wl1251_error ("request_irq() failed: %d" , ret);
@@ -267,7 +268,6 @@ static int wl1251_sdio_probe(struct sdio }irq_set_irq_type (wl->irq,IRQ_TYPE_EDGE_RISING ); -disable_irq (wl->irq); wl1251_sdio_ops.enable_irq = wl1251_enable_line_irq; wl1251_sdio_ops.disable_irq = wl1251_disable_line_irq;
drivers/net/wireless/wl1251/spi.c +1 -2
@@ -281,6 +281,7 @@ static int __devinit wl1251_spi_probe(st wl->use_eeprom = pdata->use_eeprom; +irq_set_status_flags (wl->irq,IRQ_NOAUTOEN ); ret =request_irq (wl->irq, wl1251_irq,0 ,DRIVER_NAME , wl);if (ret <0 ) {wl1251_error ("request_irq() failed: %d" , ret);
@@ -289,8 +290,6 @@ static int __devinit wl1251_spi_probe(stirq_set_irq_type (wl->irq,IRQ_TYPE_EDGE_RISING ); -disable_irq (wl->irq); - ret =wl1251_init_ieee80211 (wl);if (ret) goto out_irq;
Greg KH
maintainerPATCH 80/82 drm/i915: always use RPNSWREQ for turbo change requests
In reply to Greg KH3.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jesse Barnes <[email protected]>
commit 89ba829e38bd500f438bc08af4229204c8ed7f35 upstream.
Media turbo requests can either use RPVSWREQ or RPNSWREQ to indicate what the interrupt handler should do. Since we only deal with the latter in our turbo code, make the media engine use that for turbo requests.
--- drivers/gpu/drm/i915/intel_display.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/i915/intel_display.c +1 -1
@@ -8368,7 +8368,7 @@ void gen6_enable_rps(struct drm_i915_priI915_WRITE (GEN6_RP_IDLE_HYSTERSIS ,10 ); I915_WRITE(GEN6_RP_CONTROL, GEN6_RP_MEDIA_TURBO | - GEN6_RP_MEDIA_HW_MODE | + GEN6_RP_MEDIA_HW_NORMAL_MODE | GEN6_RP_MEDIA_IS_GFX | GEN6_RP_ENABLE | GEN6_RP_UP_BUSY_AVG |
Greg KH
maintainerPATCH 81/82 drm/i915/dp: Flush any outstanding work to turn the VDD off
In reply to Greg KH3.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chris Wilson <[email protected]>
commit 17038de5f16569a25343cf68668f3b657eafb00e upstream.
As we may kick off a delayed workqueue task to switch of the VDD lines, we need to complete that task prior to turning off the panel (which itself depends upon VDD being off).
v2: Don't cancel the outstanding work as this may trigger a deadlock
--- drivers/gpu/drm/i915/intel_dp.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/i915/intel_dp.c +1 -0
@@ -1149,6 +1149,7 @@ static void ironlake_edp_panel_off(strucDRM_DEBUG_KMS ("Turn eDP power off\n" );WARN (intel_dp->want_panel_vdd,"Cannot turn power off while VDD is on\n" ); +ironlake_panel_vdd_off_sync (intel_dp);/* finish any pending work */ pp =ironlake_get_pp_control (dev_priv); pp &= ~(POWER_TARGET_ON |EDP_FORCE_VDD |PANEL_POWER_RESET |EDP_BLC_ENABLE );
Greg KH
maintainerPATCH 82/82 drm/i915: enable vdd when switching off the eDP panel
In reply to Greg KH3.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daniel Vetter <[email protected]>
commit 6cb49835da0426f69a2931bc2a0a8156344b0e41 upstream.
We have one bug report from a validation team that we get the eDP panel sequencing still somewhat wrong: We need to enable VDD while switching off the panel and backlight. Unfortunately that reporter seems to have fallen off the earth :(
For another reporter this actually fixes a black panel issue because without this the backlight/panel gets confused and doesn't light up again.
v2: I've forgotten to remove the vdd_off call in panel_off which is now bogus. This essentially reverts
commit 17038de5f16569a25343cf68668f3b657eafb00e
Author: Chris Wilson <[email protected]> Date: Mon Apr 16 22:43:42 2012 +0100
drm/i915/dp: Flush any outstanding work to turn the VDD off
v3: the current panel_off code forces off the vdd power, too. Which is bogus and resulted in some funny warnings later on when we've tried to do aux channel communications with just the vdd forced on. Fix this, too.
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=46312
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=43163
--- drivers/gpu/drm/i915/intel_dp.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-)
drivers/gpu/drm/i915/intel_dp.c +8 -10
@@ -1148,11 +1148,10 @@ static void ironlake_edp_panel_off(strucDRM_DEBUG_KMS ("Turn eDP power off\n" ); -WARN (intel_dp->want_panel_vdd,"Cannot turn power off while VDD is on\n" ); -ironlake_panel_vdd_off_sync (intel_dp);/* finish any pending work */ +WARN (!intel_dp->want_panel_vdd,"Need VDD to turn off panel\n" ); pp =ironlake_get_pp_control (dev_priv); - pp &= ~(POWER_TARGET_ON |EDP_FORCE_VDD |PANEL_POWER_RESET |EDP_BLC_ENABLE ); + pp &= ~(POWER_TARGET_ON |PANEL_POWER_RESET |EDP_BLC_ENABLE );I915_WRITE (PCH_PP_CONTROL , pp);POSTING_READ (PCH_PP_CONTROL );
@@ -1260,18 +1259,16 @@ static void intel_dp_prepare(struct drm_ {struct intel_dp *intel_dp =enc_to_intel_dp (encoder); + +/* Make sure the panel is off before trying to change the mode. But also +* ensure that we have vdd while we switch off the panel. */ +ironlake_edp_panel_vdd_on (intel_dp);ironlake_edp_backlight_off (intel_dp);ironlake_edp_panel_off (intel_dp); -/* Wake up the sink first */ -ironlake_edp_panel_vdd_on (intel_dp);intel_dp_sink_dpms (intel_dp,DRM_MODE_DPMS_ON );intel_dp_link_down (intel_dp);ironlake_edp_panel_vdd_off (intel_dp, false); - -/* Make sure the panel is off before trying to -* change the mode -*/ }static void intel_dp_commit (struct drm_encoder *encoder)
@@ -1303,10 +1300,11 @@ intel_dp_dpms(struct drm_encoder *encodeuint32_t dp_reg =I915_READ (intel_dp->output_reg);if (mode !=DRM_MODE_DPMS_ON ) { +/* Switching the panel off requires vdd. */ +ironlake_edp_panel_vdd_on (intel_dp);ironlake_edp_backlight_off (intel_dp);ironlake_edp_panel_off (intel_dp); -ironlake_edp_panel_vdd_on (intel_dp);intel_dp_sink_dpms (intel_dp, mode);intel_dp_link_down (intel_dp);ironlake_edp_panel_vdd_off (intel_dp, false);
Greg KH
maintainercover 3.4.2-stable review
This is the start of the stable review cycle for the 3.4.2 release. There are 83 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Sat Jun 9 04:03:32 UTC 2012. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
kernel.org/pub/linux/kernel/v3.0/stable-review/patch-3.4.2-rc1.gz
and the diffstat can be found below.
thanks,
greg k-h
-------------
Makefile | 4 +- arch/arm/Kconfig | 2 +- arch/arm/mach-ixp4xx/common.c | 48 +++++++++- arch/arm/mach-ixp4xx/include/mach/gpio.h | 79 +--------------- arch/microblaze/Kconfig | 2 +- arch/mips/include/asm/mach-bcm63xx/bcm63xx_gpio.h | 1 + arch/parisc/kernel/entry.S | 30 +++--- arch/parisc/kernel/vmlinux.lds.S | 6 +- arch/x86/include/asm/pgtable-3level.h | 50 ++++++++++ arch/x86/kernel/nmi.c | 6 +- arch/x86/kernel/ptrace.c | 6 -- arch/x86/xen/enlighten.c | 3 + drivers/acpi/battery.c | 10 +- drivers/atm/solos-pci.c | 4 +- drivers/gpu/drm/i915/intel_display.c | 2 +- drivers/gpu/drm/i915/intel_dp.c | 17 ++-- drivers/gpu/drm/i915/intel_lvds.c | 8 ++ drivers/gpu/drm/i915/intel_sdvo.c | 12 ++- drivers/gpu/drm/i915/intel_sdvo_regs.h | 5 + drivers/gpu/drm/i915/intel_tv.c | 53 +++++++++++ drivers/gpu/drm/radeon/evergreen.c | 18 +++- drivers/gpu/drm/radeon/evergreend.h | 1 + drivers/gpu/drm/radeon/ni.c | 32 +++++-- drivers/gpu/drm/radeon/r600_audio.c | 5 +- drivers/gpu/drm/radeon/radeon_atombios.c | 4 +- drivers/gpu/drm/radeon/radeon_cs.c | 31 ++++--- drivers/gpu/drm/radeon/radeon_gart.c | 19 ++-- drivers/gpu/drm/radeon/rv770.c | 10 +- drivers/gpu/drm/radeon/rv770d.h | 1 + drivers/gpu/drm/ttm/ttm_bo.c | 1 + drivers/gpu/drm/vmwgfx/vmwgfx_gmr.c | 2 +- drivers/iommu/amd_iommu.c | 108 ++++++++++++++-------- drivers/iommu/amd_iommu_init.c | 13 +-- drivers/iommu/amd_iommu_types.h | 3 + drivers/md/raid1.c | 4 + drivers/md/raid10.c | 5 +- drivers/mtd/Kconfig | 2 +- drivers/mtd/devices/block2mtd.c | 1 - drivers/mtd/nand/mxc_nand.c | 12 +-- drivers/mtd/nand/nand_bbt.c | 1 + drivers/net/ethernet/freescale/fec_mpc52xx.c | 2 +- drivers/net/usb/asix.c | 3 +- drivers/net/wireless/ath/ath9k/xmit.c | 16 ++-- drivers/net/wireless/iwlwifi/iwl-2000.c | 4 +- drivers/net/wireless/iwlwifi/iwl-6000.c | 6 +- drivers/net/wireless/iwlwifi/iwl-agn-rs.c | 1 + drivers/net/wireless/wl1251/sdio.c | 2 +- drivers/net/wireless/wl1251/spi.c | 3 +- drivers/scsi/scsi_lib.c | 11 ++- drivers/scsi/scsi_wait_scan.c | 2 +- fs/attr.c | 5 + fs/cifs/cifsglob.h | 1 + fs/cifs/cifsproto.h | 6 +- fs/cifs/cifssmb.c | 12 +-- fs/cifs/file.c | 57 +++++++----- fs/cifs/readdir.c | 15 ++- fs/exofs/super.c | 2 +- fs/ext4/ialloc.c | 10 +- fs/ext4/ioctl.c | 12 ++- fs/ext4/mballoc.c | 6 +- fs/ext4/namei.c | 6 ++ fs/ext4/resize.c | 2 + fs/ext4/super.c | 4 +- fs/namespace.c | 3 +- fs/nfs/idmap.c | 10 +- fs/nfs/nfs4proc.c | 2 + fs/proc/base.c | 17 ++-- fs/proc/task_mmu.c | 2 +- include/asm-generic/pgtable.h | 22 ++++- include/drm/drm_pciids.h | 17 +++- include/linux/Kbuild | 1 + include/linux/kernel-page-flags.h | 4 + include/linux/radix-tree.h | 5 +- include/linux/skbuff.h | 2 - include/net/dst.h | 1 + kernel/fork.c | 3 +- lib/radix-tree.c | 3 + mm/hugetlb.c | 29 ++++-- mm/slub.c | 9 +- mm/vmalloc.c | 3 +- mm/vmscan.c | 2 +- net/ipv4/esp4.c | 24 ++--- net/ipv4/fib_semantics.c | 12 +-- net/ipv6/esp6.c | 18 ++-- net/ipv6/ip6_output.c | 68 ++++++++++---- net/l2tp/l2tp_ip.c | 30 ++++-- net/mac80211/util.c | 12 +-- net/sunrpc/clnt.c | 2 + net/sunrpc/xprt.c | 5 +- net/xfrm/xfrm_policy.c | 3 + sound/usb/pcm.c | 3 + tools/vm/page-types.c | 28 +----- 92 files changed, 739 insertions(+), 410 deletions(-)
Re: [ 08/82] mm: pmd_read_atomic: fix 32bit PAE pmd walk vs pmd_populate SMP race condition
In reply to Greg KHQuoted 11 lines · Greg KH
3.4-stable review patch. �If anyone has any objections, please let me know.
------------------
From: Andrea Arcangeli <[email protected]>
commit
26c191788f18129af0eb32a358cdaea0c7479626upstream.When holding the
mmap_semfor reading,pmd_offset_map_lockshould only run on apmd_tthat has been read atomically from the pmdp pointer, otherwise we may read only half of it leading to this crash.
This one is important, but it can break Xen apparently:
http://permalink.gmane.org/gmane.comp.emulators.xen.devel/132522
https://bugzilla.redhat.com/show_bug.cgi?id=829016
Not sure if you want to hold off on it or see if Andrea comes up with a follow up fix?
josh
Re: [ 08/82] mm: pmd_read_atomic: fix 32bit PAE pmd walk vs pmd_populate SMP race condition
Hi,
Quoted 13 lines · Josh Boyer
Quoted 11 lines · Greg KH
3.4-stable review patch. �If anyone has any objections, please let me know.
------------------
From: Andrea Arcangeli <[email protected]>
commit
26c191788f18129af0eb32a358cdaea0c7479626upstream.When holding the
mmap_semfor reading,pmd_offset_map_lockshould only run on apmd_tthat has been read atomically from the pmdp pointer, otherwise we may read only half of it leading to this crash.
Quoted 7 lines
This one is important, but it can break Xen apparently:
http://permalink.gmane.org/gmane.comp.emulators.xen.devel/132522
https://bugzilla.redhat.com/show_bug.cgi?id=829016Not sure if you want to hold off on it or see if Andrea comes up with a follow up fix?
Not knowing exactly why Xen trips on the atomic64_read on a PAE 32bit pmd on my side, I don't know what's the best direction to fix it yet.
I knew this fix has been tested and was working fine with Xen + CONFIG_TRANSPARENT_HUGEPAGE=n + 32bit + x86 + PAE. And when THP=n I could fix the problem without having to use a slightly more expensive cmpxchg8b for every pmd read happening with the mmap_sem hold in read mode.
It was totally unexpected to run into trouble with Xen + CONFIG_TRANSPARENT_HUGEPAGE=y + 32bit + x86 + PAE, apologies.
Quoted 1 line
From the oops it looks like
atomic64_readtrips on a dangling pmdp
pointer, but if the problem doesn't happen with Xen then the pointer value shouldn't be the problem, and in turn the lock cmpxchg8b used to access the pointer is likely the problem.
I gave a few suggestions on how to fix it, that should work regardless of why this is happening, but I'd prefer the Xen developers to comment on that.
https://bugzilla.redhat.com/attachment.cgi?id=589620
<f0> 0f c7 09 c3 8d 76 0
f0 0f is the infamous opcode lock cmpxchg8b so it confirms it trips exactly on the pmdp read.
ecx/edx = dcaea360 and "BUG: unable to handle kernel paging request at dcaea360" are probably all right, my best guess is that the insn used to read the pmd is unexpected.
Re: [ 08/82] mm: pmd_read_atomic: fix 32bit PAE pmd walk vs pmd_populate SMP race condition
Quoted 5 lines · Andrea Arcangeli
From the oops it looks like
atomic64_readtrips on a dangling pmdp pointer, but if the problem doesn't happen with Xen then the pointer value shouldn't be the problem, and in turn the lock cmpxchg8b used to access the pointer is likely the problem.
So I assume that Xen just turns the page tables read-only in order to track them, and then assumes that nobody modifies them in the particular section. And the cmpxchg64 looks like a modification, even if we only use it to read things.
Andrea, do we have any guarantees like "once it has turned into a regular page table, we won't see it turn back if we hold the mmap sem"? Or anything like that? Because it is possible that we could do this entirely with some ordering guarantee - something like the attached patch?
Totally untested, of course.
Linus
arch/x86/include/asm/pgtable-3level.h | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-)
arch/x86/include/asm/pgtable-3level.h +15 -14
@@ -53,33 +53,34 @@ static inline void native_set_pte(pte_t *ptep, pte_t pte)* * With THP if the mmap_sem is hold for reading, the pmd can become * THP or null or point to a pte (and in turn become "stable") at any -* time under pmd_read_atomic, so it's mandatory to read it atomically -* with cmpxchg8b. +* time under pmd_read_atomic, so we have to be really careful. We'll +* re-read the low word to check that it hasn't become NULL or turned +* into a pte. */ -#ifndef CONFIG_TRANSPARENT_HUGEPAGE static inline pmd_t pmd_read_atomic (pmd_t *pmdp) {pmdval_t ret; -u32 *tmp = (u32 *)pmdp; +u32 low, hight, *tmp = (u32 *)pmdp; - ret = (pmdval_t) (*tmp); -if (ret) { +repeat: + low = tmp[0 ]; + high =0 ; +if (low) {/* * If the low part is null, we must not read the high part * or we can end up with a partial pmd. */ smp_rmb (); - ret |= ((pmdval_t)*(tmp +1 )) <<32 ; + high = tmp[1 ]; +if (IS_ENABLED (CONFIG_TRANSPARENT_HUGEPAGE )) { +smp_rmb (); +if (low != tmp[0 ]) + goto repeat; + } } -return (pmd_t ) { ret }; +return (pmd_t ) { low + ((u64 )high <<32 ) }; } -#else /* CONFIG_TRANSPARENT_HUGEPAGE */ -static inline pmd_t pmd_read_atomic (pmd_t *pmdp) -{ -return (pmd_t ) {atomic64_read ((atomic64_t *)pmdp) }; -} -#endif /* CONFIG_TRANSPARENT_HUGEPAGE */ static inline void native_set_pte_atomic (pte_t *ptep,pte_t pte) {
Re: [ 08/82] mm: pmd_read_atomic: fix 32bit PAE pmd walk vs pmd_populate SMP race condition
In reply to Greg KHQuoted 1 line · Greg KH
3.4-stable review patch. If anyone has any objections, please let me know.
It breaks Linux running under Amazon EC2 under 32-bit. Please don't apply it to any 3.x kernels until we figure out a fix to this.
Quoted 218 lines
------------------
From: Andrea Arcangeli <[email protected]>
commit
26c191788f18129af0eb32a358cdaea0c7479626upstream.When holding the
mmap_semfor reading,pmd_offset_map_lockshould only run on apmd_tthat has been read atomically from the pmdp pointer, otherwise we may read only half of it leading to this crash.PID: 11679 TASK:
f06e8000CPU: 3 COMMAND: "do_race_2_panic"
#0 [f06a9dd8]crash_kexecatc049b5ec
#1 [f06a9e2c]oops_endatc083d1c2
#2 [f06a9e40]no_contextatc0433ded
#3 [f06a9e64]bad_area_nosemaphoreatc043401a#4 [f06a9e6c]__do_page_faultatc0434493
#5 [f06a9eec]do_page_faultatc083eb45
#6 [f06a9f04]error_code(viapage_fault) atc083c5d5EAX: 01fb470c EBX: fff35000 ECX: 00000003 EDX: 00000100 EBP: 00000000 DS: 007b ESI: 9e201000 ES: 007b EDI: 01fb4700 GS: 00e0 CS: 0060 EIP: c083bc14 ERR: ffffffff EFLAGS: 00010246 #7 [f06a9f38] _spin_lock at c083bc14 #8 [f06a9f44] sys_mincore at c0507b7d #9 [f06a9fb0] system_call at c083becd start len EAX: ffffffda EBX: 9e200000 ECX: 00001000 EDX: 6228537f DS: 007b ESI: 00000000 ES: 007b EDI: 003d0f00 SS: 007b ESP: 62285354 EBP: 62285388 GS: 0033 CS: 0073 EIP: 00291416 ERR: 000000da EFLAGS: 00000286This should be a longstanding bug affecting x86 32bit PAE without THP. Only archs with 64bit large
pmd_tand 32bit unsigned long should be affected.With THP enabled the
barrier()inpmd_none_or_trans_huge_or_clear_bad()would partly hide the bug when the pmd transition from none to stable, by forcing a re-read of the *pmd inpmd_offset_map_lock, but when THP is enabled a new set of problem arises by the fact could then transition freely in any of the none,pmd_trans_hugeorpmd_trans_stablestates. So making the barrier inpmd_none_or_trans_huge_or_clear_bad()unconditional isn't good idea and it would be a flakey solution.This should be fully fixed by introducing a
pmd_read_atomicthat reads the pmd in order with THP disabled, or by reading the pmd atomically with cmpxchg8b with THP enabled.Luckily this new race condition only triggers in the places that must already be covered by
pmd_none_or_trans_huge_or_clear_bad()so the fix is localized there but this bug is not related to THP.NOTE: this can trigger on x86 32bit systems with PAE enabled with more than 4G of ram, otherwise the high part of the pmd will never risk to be truncated because it would be zero at all times, in turn so hiding the SMP race.
This bug was discovered and fully debugged by Ulrich, quote:
----
[..]pmd_none_or_trans_huge_or_clear_bad()loads the content of edx and eax.496 static inline int pmd_none_or_trans_huge_or_clear_bad(pmd_t *pmd) 497 { 498 /* depend on compiler for an atomic pmd read */ 499 pmd_t pmdval = *pmd; // edi = pmd pointer 0xc0507a74 <sys_mincore+548>: mov 0x8(%esp),%edi ... // edx = PTE page table high address 0xc0507a84 <sys_mincore+564>: mov 0x4(%edi),%edx ... // eax = PTE page table low address
0xc0507a8e<sys_mincore+574>: mov (%edi),%eax[..]
Please note that the PMD is not read atomically. These are two "mov" instructions where the high order bits of the PMD entry are fetched first. Hence, the above machine code is prone to the following race.
(quoted diff) +0
-4- The PMD entry {high|low} is 0x0000000000000000. The "mov" at 0xc0507a84 loads 0x00000000 into edx. - A page fault (on another CPU) sneaks in between the two "mov" instructions and instantiates the PMD. - The PMD entry {high|low} is now 0x00000003fda38067. The "mov" at 0xc0507a8e loads 0xfda38067 into eax. ----Reported-by Ulrich Obergfell <[email protected]>Signed-off-by Andrea Arcangeli <[email protected]>Cc Mel Gorman <[email protected]>Cc Hugh Dickins <[email protected]>Cc Larry Woodman <[email protected]>Cc Petr Matousek <[email protected]>Cc Rik van Riel <[email protected]>Signed-off-by Andrew Morton <[email protected]>Signed-off-by Linus Torvalds <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>--- arch/x86/include/asm/pgtable-3level.h | 50 ++++++++++++++++++++++++++++++++++ include/asm-generic/pgtable.h | 22 +++++++++++++- 2 files changed, 70 insertions(+), 2 deletions(-)arch/x86/include/asm/pgtable-3level.h +50
-0@@ -31,6 +31,56 @@ static inline void native_set_pte(pte_t ptep->pte_low = pte.pte_low; } +#define pmd_read_atomic pmd_read_atomic +/* +* pte_offset_map_lock on 32bit PAE kernels was reading the pmd_t with +* a "*pmdp" dereference done by gcc. Problem is, in certain places +* where pte_offset_map_lock is called, concurrent page faults are +* allowed, if the mmap_sem is hold for reading. An example is mincore +* vs page faults vs MADV_DONTNEED. On the page fault side +* pmd_populate rightfully does a set_64bit, but if we're reading the +* pmd_t with a "*pmdp" on the mincore side, a SMP race can happen +* because gcc will not read the 64bit of the pmd atomically. To fix +* this all places running pmd_offset_map_lock() while holding the +* mmap_sem in read mode, shall read the pmdp pointer using this +* function to know if the pmd is null nor not, and in turn to know if +* they can run pmd_offset_map_lock or pmd_trans_huge or other pmd +* operations. +* +* Without THP if the mmap_sem is hold for reading, the +* pmd can only transition from null to not null while pmd_read_atomic runs. +* So there's no need of literally reading it atomically. +* +* With THP if the mmap_sem is hold for reading, the pmd can become +* THP or null or point to a pte (and in turn become "stable") at any +* time under pmd_read_atomic, so it's mandatory to read it atomically +* with cmpxchg8b. +*/ +#ifndef CONFIG_TRANSPARENT_HUGEPAGE +static inline pmd_t pmd_read_atomic (pmd_t *pmdp) +{ +pmdval_t ret; +u32 *tmp = (u32 *)pmdp; + + ret = (pmdval_t) (*tmp); +if (ret) { +/* +* If the low part is null, we must not read the high part +* or we can end up with a partial pmd. +*/ +smp_rmb (); + ret |= ((pmdval_t)*(tmp +1 )) <<32 ; + } + +return (pmd_t ) { ret }; +} +#else /* CONFIG_TRANSPARENT_HUGEPAGE */ +static inline pmd_t pmd_read_atomic (pmd_t *pmdp) +{ +return (pmd_t ) {atomic64_read ((atomic64_t *)pmdp) }; +} +#endif /* CONFIG_TRANSPARENT_HUGEPAGE */ +static inline void native_set_pte_atomic (pte_t *ptep,pte_t pte) {set_64bit ((unsigned long long *)(ptep),native_pte_val (pte));include/asm-generic/pgtable.h +20
-3@@ -446,6 +446,18 @@ static inline int pmd_write(pmd_t pmd)#endif /* __HAVE_ARCH_PMD_WRITE */ #endif /* CONFIG_TRANSPARENT_HUGEPAGE */ +#ifndef pmd_read_atomic +static inline pmd_t pmd_read_atomic (pmd_t *pmdp) +{ +/* +* Depend on compiler for an atomic pmd read. NOTE: this is +* only going to work, if the pmdval_t isn't larger than +* an unsigned long. +*/ +return *pmdp; +} +#endif +/* * This function is meant to be used by sites walking pagetables with * the mmap_sem hold in read mode to protect against MADV_DONTNEED and @@ -459,11 +471,17 @@ static inline int pmd_write(pmd_t pmd)* undefined so behaving like if the pmd was none is safe (because it * can return none anyway). The compiler level barrier() is critically * important to compute the two checks atomically on the same pmdval. +* +* For 32bit kernels with a 64bit large pmd_t this automatically takes +* care of reading the pmd atomically to avoid SMP race conditions +* against pmd_populate() when the mmap_sem is hold for reading by the +* caller (a special atomic read not done by "gcc" as in the generic +* version above, is also needed when THP is disabled because the page +* fault can populate the pmd from under us). */ static inline int pmd_none_or_trans_huge_or_clear_bad (pmd_t *pmd) { -/* depend on compiler for an atomic pmd read */ -pmd_t pmdval = *pmd; +pmd_t pmdval =pmd_read_atomic (pmd);/* * The barrier will stabilize the pmdval in a register or on * the stack so that it will stop changing under the code. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Re: [ 08/82] mm: pmd_read_atomic: fix 32bit PAE pmd walk vs pmd_populate SMP race condition
In reply to Linus TorvaldsQuoted 4 lines · Linus Torvalds
So I assume that Xen just turns the page tables read-only in order to track them, and then assumes that nobody modifies them in the particular section. And the cmpxchg64 looks like a modification, even if we only use it to read things.
Agreed, the implicit write could be the trigger.
Quoted 3 lines
Andrea, do we have any guarantees like "once it has turned into a regular page table, we won't see it turn back if we hold the mmap sem"? Or anything like that? Because it is possible that we could do
Yes if it turns in a regular page table it will stop changing.
The problem is this is the THP case. Without THP it can only change from nono to regular page table. With THP it can change from none to trans_huge to none to trans_huge and it only stops if it eventually becomes a regular page table.
Quoted 2 lines
this entirely with some ordering guarantee - something like the attached patch?
It's possible to do it with a loop like in the patch, gup_fast does it that way (and gup_fast does it on the pte so the pte is susciptible to the exact same instability that the pmd has even when THP=n, as madvise/pagefault can run under gup_fast), but I'm not sure if it's safe especially with irqs enabled. Maybe gup_fast is safe because it disables irqs to stop MADV_DONTNEED?
The race would be:
l = pmd.low
smp_rmb()
h = pmd.high
smp_rmb()
pmd points to page 4G MADV_DONTNEED
page fault allocates page at 8G
l = pmd.low
Disabling irqs may be enough to hang MADV_DONTNEED on the tlb flush IPI. But my feeling is the page fault can happen even while MADV_DONTNEED waits on the tlb flush IPI. So the above could still happen on gup_fast too? But of course gup_fast troubles are irrelevant here, but I was thinking about this one before... so I mentioned it too as it's the same problem.
The "simple" idea in pmd_none_or_trans_huge_or_clear_bad is that we need an atomic snapshot of the pmdval, stabilize it in register or local stack, and do the computations on it to know if the pmd is stable or unstable.
But the more "complex" idea would be to relay on the below barrier and deal with "half corrupted" pmds.
#ifdef CONFIG_TRANSPARENT_HUGEPAGE barrier();
#endif
the barrier prevents the *pmdp read to be cached across the return of pmd_none_or_trans_huge_or_clear_bad when THP=y (our problem case). And all we need is to compute those checks atomically on the "low" part.
if (pmd_none(pmdval))
return 1;
if (unlikely(pmd_bad(pmdval))) {
if (!pmd_trans_huge(pmdval))
pmd_clear_bad(pmd);
return 1;
}If we remove the #ifdef CONFIG_TRANSPARENT_HUGEPAGE around the barrier(), we can get rid of pmd_read_atomic entirely and just do *pmd as before the fix (however note that if we triggered the crash in madvise with 32bit pae THP=n it means the value was cached by gcc and the corrupted pmdval was used for running pte_offset). So if we make the barrier() unconditional we'll force a second access to memory. This is the whole point of the barrier() conditional (to avoid screwing with gcc good work when not absolutely necessary).
Anyway I made a patch below to take advantage of the barrier() and deal with corrupted pmds on pae 32bit x86 THP=y which I hope could fix this more optimally:
arch/x86/include/asm/pgtable-3level.h +10 -8
@@ -31,7 +31,6 @@ static inline void native_set_pte(pte_t *ptep, pte_t pte) ptep->pte_low = pte.pte_low; } -#define pmd_read_atomic pmd_read_atomic/* * pte_offset_map_lock on 32bit PAE kernels was reading the pmd_t with * a "*pmdp" dereference done by gcc. Problem is, in certain places
@@ -53,10 +52,18 @@ static inline void native_set_pte(pte_t *ptep, pte_t pte)* * With THP if the mmap_sem is hold for reading, the pmd can become * THP or null or point to a pte (and in turn become "stable") at any -* time under pmd_read_atomic, so it's mandatory to read it atomically -* with cmpxchg8b. +* time under pmd_read_atomic. We could read it atomically here with a +* pmd_read_atomic using atomic64_read for the THP case, but instead +* we let the generic version of pmd_read_atomic run, and we instead +* relay on the barrier() in pmd_none_or_trans_huge_or_clear_bad() to +* prevent gcc to cache the potentially corrupted pmdval in pte_offset +* later. The barrier() will force the re-reading of the pmd and the +* checks in pmd_none_or_trans_huge_or_clear_bad() will only care +* about the low part of the pmd, regardless if the high part is +* consistent. */ #ifndef CONFIG_TRANSPARENT_HUGEPAGE +#define pmd_read_atomic pmd_read_atomicstatic inline pmd_t pmd_read_atomic (pmd_t *pmdp) {pmdval_t ret;
@@ -74,11 +81,6 @@ static inline pmd_t pmd_read_atomic(pmd_t *pmdp) return (pmd_t) { ret }; } -#else /* CONFIG_TRANSPARENT_HUGEPAGE */ -static inline pmd_t pmd_read_atomic (pmd_t *pmdp) -{ -return (pmd_t ) {atomic64_read ((atomic64_t *)pmdp) }; -}#endif /* CONFIG_TRANSPARENT_HUGEPAGE */ static inline void native_set_pte_atomic (pte_t *ptep,pte_t pte)
include/asm-generic/pgtable.h +7 -0
@@ -484,6 +484,13 @@ static inline int pmd_none_or_trans_huge_or_clear_bad(pmd_t *pmd)/* * The barrier will stabilize the pmdval in a register or on * the stack so that it will stop changing under the code. +* +* The barrier for the "x86 32bit PAE +* CONFIG_TRANSPARENT_HUGEPAGE=y" case will also prevent an +* inconsistent pmd low/high values (obtained by the generic +* version of pmd_read_atomic) to be cached by gcc. The below +* checks will only care about the low part of the pmd with +* 32bit PAE. */ #ifdef CONFIG_TRANSPARENT_HUGEPAGE barrier ();
Re: [ 08/82] mm: pmd_read_atomic: fix 32bit PAE pmd walk vs pmd_populate SMP race condition
Hi,
this should avoid the cmpxchg8b (to make Xen happy) but without reintroducing the race condition. It's actually going to be faster too, but it's conceptually more complicated as the pmd high/low may be inconsistent at times, but at those times we're going to declare the pmd unstable and ignore it anyway so it's ok.
NOTE: in theory I could also drop the high part when THP=y thanks to the barrier() in the caller (and the barrier is needed for the generic version anyway):
static inline pmd_t pmd_read_atomic(pmd_t *pmdp)
{
pmdval_t ret;
u32 *tmp = (u32 *)pmdp;
ret = (pmdval_t) (*tmp);
+#ifndef CONFIG_TRANSPARENT_HUGEPAGE
if (ret) {
/*
* If the low part is null, we must not read the high part
* or we can end up with a partial pmd.
*/
smp_rmb();
ret |= ((pmdval_t)*(tmp + 1)) << 32;
}+#endif
return (pmd_t) { ret };
}But it's not worth the extra complexity. It looks cleaner if we deal with "good" pmds if they're later found pointing to a pte (even if we discard them and force pte_offset to re-read the *pmd).
Andrea Arcangeli (1):
thp: avoid atomic64_read in pmd_read_atomic for 32bit PAE
arch/x86/include/asm/pgtable-3level.h | 30 +++++++++++++++++------------- include/asm-generic/pgtable.h | 10 ++++++++++ 2 files changed, 27 insertions(+), 13 deletions(-)
PATCH 1/1 thp: avoid atomic64_read in pmd_read_atomic for 32bit PAE
In reply to Andrea ArcangeliIn the x86 32bit PAE CONFIG_TRANSPARENT_HUGEPAGE=y case while holding the mmap_sem for reading, cmpxchg8b cannot be used to read pmd contents under Xen.
So instead of dealing only with "consistent" pmdvals in pmd_none_or_trans_huge_or_clear_bad() (which would be conceptually simpler) we let pmd_none_or_trans_huge_or_clear_bad() deal with pmdvals where the low 32bit and high 32bit could be inconsistent (to avoid having to use cmpxchg8b).
The only guarantee we get from pmd_read_atomic is that if the low part of the pmd was found null, the high part will be null too (so the pmd will be considered unstable). And if the low part of the pmd is found "stable" later, then it means the whole pmd was read atomically (because after a pmd is stable, neither MADV_DONTNEED nor page faults can alter it anymore, and we read the high part after the low part).
In the 32bit PAE x86 case, it is enough to read the low part of the pmdval atomically to declare the pmd as "stable" and that's true for THP and no THP, furthermore in the THP case we also have a barrier() that will prevent any inconsistent pmdvals to be cached by a later re-read of the *pmd.
--- arch/x86/include/asm/pgtable-3level.h | 30 +++++++++++++++++------------- include/asm-generic/pgtable.h | 10 ++++++++++ 2 files changed, 27 insertions(+), 13 deletions(-)
arch/x86/include/asm/pgtable-3level.h +17 -13
@@ -47,16 +47,26 @@ static inline void native_set_pte(pte_t *ptep, pte_t pte)* they can run pmd_offset_map_lock or pmd_trans_huge or other pmd * operations. * -* Without THP if the mmap_sem is hold for reading, the -* pmd can only transition from null to not null while pmd_read_atomic runs. -* So there's no need of literally reading it atomically. +* Without THP if the mmap_sem is hold for reading, the pmd can only +* transition from null to not null while pmd_read_atomic runs. So +* we can always return atomic pmd values with this function. * * With THP if the mmap_sem is hold for reading, the pmd can become -* THP or null or point to a pte (and in turn become "stable") at any -* time under pmd_read_atomic, so it's mandatory to read it atomically -* with cmpxchg8b. +* trans_huge or none or point to a pte (and in turn become "stable") +* at any time under pmd_read_atomic. We could read it really +* atomically here with a atomic64_read for the THP enabled case (and +* it would be a whole lot simpler), but to avoid using cmpxchg8b we +* only return an atomic pmdval if the low part of the pmdval is later +* found stable (i.e. pointing to a pte). And we're returning a none +* pmdval if the low part of the pmd is none. In some cases the high +* and low part of the pmdval returned may not be consistent if THP is +* enabled (the low part may point to previously mapped hugepage, +* while the high part may point to a more recently mapped hugepage), +* but pmd_none_or_trans_huge_or_clear_bad() only needs the low part +* of the pmd to be read atomically to decide if the pmd is unstable +* or not, with the only exception of when the low part of the pmd is +* zero in which case we return a none pmd. */ -#ifndef CONFIG_TRANSPARENT_HUGEPAGE static inline pmd_t pmd_read_atomic (pmd_t *pmdp) {pmdval_t ret;
@@ -74,12 +84,6 @@ static inline pmd_t pmd_read_atomic(pmd_t *pmdp)return (pmd_t ) { ret }; } -#else /* CONFIG_TRANSPARENT_HUGEPAGE */ -static inline pmd_t pmd_read_atomic (pmd_t *pmdp) -{ -return (pmd_t ) {atomic64_read ((atomic64_t *)pmdp) }; -} -#endif /* CONFIG_TRANSPARENT_HUGEPAGE */ static inline void native_set_pte_atomic (pte_t *ptep,pte_t pte) {
include/asm-generic/pgtable.h +10 -0
@@ -484,6 +484,16 @@ static inline int pmd_none_or_trans_huge_or_clear_bad(pmd_t *pmd)/* * The barrier will stabilize the pmdval in a register or on * the stack so that it will stop changing under the code. +* +* When CONFIG_TRANSPARENT_HUGEPAGE=y on x86 32bit PAE, +* pmd_read_atomic is allowed to return a not atomic pmdval +* (for example pointing to an hugepage that has never been +* mapped in the pmd). The below checks will only care about +* the low part of the pmd with 32bit PAE x86 anyway, with the +* exception of pmd_none(). So the important thing is that if +* the low part of the pmd is found null, the high part will +* be also null or the pmd_none() check below would be +* confused. */ #ifdef CONFIG_TRANSPARENT_HUGEPAGE barrier ();
Re: [ 08/82] mm: pmd_read_atomic: fix 32bit PAE pmd walk vs pmd_populate SMP race condition
In reply to Andrea ArcangeliQuoted 7 lines · Andrea Arcangeli
#ifndef
CONFIG_TRANSPARENT_HUGEPAGEarch/x86/include/asm/pgtable-3level.h +1
-0+#define pmd_read_atomic pmd_read_atomicstatic inline pmd_t pmd_read_atomic (pmd_t *pmdp) {pmdval_t ret;@@ -74,11 +81,6 @@ static inline pmd_t pmd_read_atomic(pmd_t *pmdp)
arch/x86/include/asm/pgtable-3level.h static inline pmd_t pmd_read_atomic(pmd_t *pmdp) · line 86
Quoted 10 lines
arch/x86/include/asm/pgtable-3level.h +0
-5return (pmd_t) { ret }; } -#else /* CONFIG_TRANSPARENT_HUGEPAGE */ -static inline pmd_t pmd_read_atomic (pmd_t *pmdp) -{ -return (pmd_t ) {atomic64_read ((atomic64_t *)pmdp) }; -}#endif /* CONFIG_TRANSPARENT_HUGEPAGE */ static inline void native_set_pte_atomic (pte_t *ptep,pte_t pte)
This actually wasn't safe because if the high part wasn't none and the low part was none, the pmd_none check would fail. I sent an updated version that will fix this hopefully for good and it turns out the same pmd_read_atomic will work for THP=n/y without need of cmpxchg8b even if it's slightly less obviously safe than if we used atomic64_read for THP=y. Still safe that is...
Re: [ 53/82] asix: allow full size 8021Q frames to be received
In reply to Greg KHQuoted 5 lines · Greg KH
3.4-stable review patch. If anyone has any objections, please let me know.
------------------
Quoted 8 lines
From: Eric Dumazet <[email protected]>
[ Upstream commit
9dae31009b1a00d926c6fe032d5a88099620adc3]asix driver drops 8021Q full size frames because it doesn't take into account VLAN header size.
Tested on AX88772 adapter.
[...]
This should presumably go into earlier stable versions as well (specifically requested for 3.2 in <http://bugs.debian.org/676545>).
Does the attached backport look reasonable?
Ben.
Signature · 2 lines
Ben Hutchings I haven't lost my mind; it's backed up on tape somewhere.
From: Eric Dumazet <[email protected]>
Date: Mon, 28 May 2012 22:31:41 +0000
Subject: asix: allow full size 8021Q frames to be received
commit 9dae31009b1a00d926c6fe032d5a88099620adc3 upstream.
asix driver drops 8021Q full size frames because it doesn't take into account VLAN header size.
Tested on AX88772 adapter.
---
drivers/net/usb/asix.c +2 -1
@@ -35,6 +35,7 @@#include <linux/crc32.h> #include <linux/usb/usbnet.h> #include <linux/slab.h> +#include <linux/if_vlan.h> #define DRIVER_VERSION "08-Nov-2011"#define DRIVER_NAME "asix"
@@ -348,7 +349,7 @@return 2 ; } -if (size > dev->net->mtu +ETH_HLEN ) { +if (size > dev->net->mtu +ETH_HLEN +VLAN_HLEN ) {netdev_err (dev->net,"asix_rx_fixup() Bad RX Length %d\n" , size);return 0 ;
Re: [ 64/82] ext4: dont trash state flags in EXT4_IOC_SETFLAGS
In reply to Greg KHQuoted 14 lines · Greg KH
3.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Theodore Ts'o <[email protected]>
commit
79906964a187c405db72a3abc60eb9b50d804fbcupstream.In commit
353eb83cwe removedi_state_flagswith 64-bit longs, But when handling theEXT4_IOC_SETFLAGSioctl, we replacei_flagsdirectly, which trashes the state flags which are stored in the high 32-bits ofi_flagson 64-bit platforms. So use the the ext4_{set,clear}_inode_flags() functions which use atomic bit manipulation functions instead.
[...]
Quoted 5 lines
fs/ext4/ioctl.c +0
-1@@ -115,8 +115,14 @@ long ext4_ioctl(struct file *filp, unsigif (err) goto flags_err; - flags = flags &EXT4_FL_USER_MODIFIABLE ;
fs/ext4/ioctl.c long ext4_ioctl(struct file *filp, unsig · line 126
Quoted 10 lines
fs/ext4/ioctl.c +8
-1- flags |= oldflags & ~EXT4_FL_USER_MODIFIABLE ; +for (i =0 , mask =1 ; i <32 ; i++, mask <<=1 ) { +if (!(mask &EXT4_FL_USER_MODIFIABLE )) +continue ; +if (mask & flags) +ext4_set_inode_flag (inode, i); +else +ext4_clear_inode_flag (inode, i); + } ei->i_flags = flags;
[...]
Shouldn't this last assignment have been deleted?
Ben.
Signature · 2 lines
Ben Hutchings I haven't lost my mind; it's backed up on tape somewhere.
Ted Ts'o
maintainerRe: [ 64/82] ext4: dont trash state flags in EXT4_IOC_SETFLAGS
Quoted 4 lines · Ben Hutchings
Quoted 1 line
ei->i_flags= flags;[...]
Shouldn't this last assignment have been deleted?
Yes, I'm testing two patches to push to Linus. One of them deletes the last assignment.
The testing cycle should be over by tomorrow morning; in the mean time, this commit is harmless in its current form (although it won't fix the problem it was intending to fix until we delete the last line).
- Ted
commit b22b1f178f6799278d3178d894f37facb2085765
Author: Tao Ma <[email protected]> Date: Thu Jun 7 19:04:19 2012 -0400
ext4: don't set i_flags in EXT4_IOC_SETFLAGS
Commit 7990696 uses the ext4_{set,clear}_inode_flags() functions to change the i_flags automatically but fails to remove the error setting of i_flags. So we still have the problem of trashing state flags. Fix this by removing the assignment.
fs/ext4/ioctl.c +0 -1
@@ -123,7 +123,6 @@ long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)else ext4_clear_inode_flag (inode, i); } - ei->i_flags = flags;ext4_set_inode_flags (inode); inode->i_ctime =ext4_current_time (inode);
Re: [ 64/82] ext4: dont trash state flags in EXT4_IOC_SETFLAGS
Quoted 6 lines · Ted Ts'o
Quoted 4 lines · Ben Hutchings
Quoted 1 line
ei->i_flags= flags;[...]
Shouldn't this last assignment have been deleted?
Quoted 7 lines
Yes, I'm testing two patches to push to Linus. One of them deletes the last assignment.
The testing cycle should be over by tomorrow morning; in the mean time, this commit is harmless in its current form (although it won't fix the problem it was intending to fix until we delete the last line).
[...]
It's not harmless because the user is no longer restricted to changing EXT4_FL_USER_MODIFIABLE.
Ben.
Signature · 2 lines
Ben Hutchings I haven't lost my mind; it's backed up on tape somewhere.
David Miller
maintainerRe: [ 53/82] asix: allow full size 8021Q frames to be received
In reply to Ben HutchingsFrom: Ben Hutchings <[email protected]>
Date: Fri, 08 Jun 2012 03:27:52 +0100
Quoted 13 lines · Greg KH
Quoted 12 lines
3.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit
9dae31009b1a00d926c6fe032d5a88099620adc3]asix driver drops 8021Q full size frames because it doesn't take into account VLAN header size.
Quoted 7 lines
Quoted 1 line
Tested on AX88772 adapter.
[...]
This should presumably go into earlier stable versions as well (specifically requested for 3.2 in <http://bugs.debian.org/676545>).
Does the attached backport look reasonable?
Yes, thanks Ben.
Greg KH
maintainerRe: [ 08/82] mm: pmd_read_atomic: fix 32bit PAE pmd walk vs pmd_populate SMP race condition
In reply to Josh BoyerQuoted 13 lines · Josh Boyer
Quoted 11 lines · Greg KH
3.4-stable review patch. �If anyone has any objections, please let me know.
------------------
From: Andrea Arcangeli <[email protected]>
commit
26c191788f18129af0eb32a358cdaea0c7479626upstream.When holding the
mmap_semfor reading,pmd_offset_map_lockshould only run on apmd_tthat has been read atomically from the pmdp pointer, otherwise we may read only half of it leading to this crash.
Quoted 7 lines
This one is important, but it can break Xen apparently:
http://permalink.gmane.org/gmane.comp.emulators.xen.devel/132522
https://bugzilla.redhat.com/show_bug.cgi?id=829016Not sure if you want to hold off on it or see if Andrea comes up with a follow up fix?
Ok, for now, I'll drop it.
When Andrea gets this fixed up, can someone let me know so I can apply this one again, and the fixup?
thanks,
greg k-h
Ted Ts'o
maintainerRe: [ 64/82] ext4: dont trash state flags in EXT4_IOC_SETFLAGS
In reply to Ben HutchingsQuoted 3 lines · Ben Hutchings
It's not harmless because the user is no longer restricted to changing
EXT4_FL_USER_MODIFIABLE.
Um, very good point. So we should either drop this commit and wait until the next stable release, or also pull commit b22b1f178f6 in as well. Basically, this commit and b22b1f178f6 should appear in the same stable release.
- Ted
Re: [ 64/82] ext4: dont trash state flags in EXT4_IOC_SETFLAGS
Quoted 9 lines · Ted Ts'o
Quoted 3 lines · Ben Hutchings
It's not harmless because the user is no longer restricted to changing
EXT4_FL_USER_MODIFIABLE.Um, very good point. So we should either drop this commit and wait until the next stable release, or also pull commit
b22b1f178f6in as well. Basically, this commit andb22b1f178f6should appear in the same stable release.
I've (re-)queued them both for 3.2.20.
Ben.
Signature · 2 lines
Ben Hutchings I haven't lost my mind; it's backed up on tape somewhere.
Ted Ts'o
maintainerRe: [ 64/82] ext4: dont trash state flags in EXT4_IOC_SETFLAGS
Quoted 6 lines · Ben Hutchings
Quoted 4 lines
Um, very good point. So we should either drop this commit and wait until the next stable release, or also pull commit
b22b1f178f6in as well. Basically, this commit andb22b1f178f6should appear in the same stable release.I've (re-)queued them both for 3.2.20.
Hey Ben,
If you haven't also queued b0dd6b70f0 (ext4: fix the free blocks calculation for ext3 file systems w/ uninit_bg) could you do me a favor and also include that in 3.2.20? I'd really like to get that into various distro kernels as quickly as possible. (i.e., Debian, et. al.)
Thanks!!
- Ted
Re: [ 64/82] ext4: dont trash state flags in EXT4_IOC_SETFLAGS
Quoted 8 lines · Ted Ts'o
Quoted 6 lines · Ben Hutchings
Quoted 4 lines
Um, very good point. So we should either drop this commit and wait until the next stable release, or also pull commit
b22b1f178f6in as well. Basically, this commit andb22b1f178f6should appear in the same stable release.I've (re-)queued them both for 3.2.20.
Quoted 7 lines
Hey Ben,
If you haven't also queued
b0dd6b70f0(ext4: fix the free blocks calculation for ext3 file systems w/uninit_bg) could you do me a favor and also include that in 3.2.20? I'd really like to get that into various distro kernels as quickly as possible. (i.e., Debian, et. al.)
Hmm, OK, that looks pretty serious.
Ben.
Signature · 2 lines
Ben Hutchings 73.46% of all statistics are made up.
Greg KH
maintainerRe: [ 64/82] ext4: dont trash state flags in EXT4_IOC_SETFLAGS
In reply to Ted Ts'oQuoted 9 lines · Ted Ts'o
Quoted 3 lines · Ben Hutchings
It's not harmless because the user is no longer restricted to changing
EXT4_FL_USER_MODIFIABLE.Um, very good point. So we should either drop this commit and wait until the next stable release, or also pull commit
b22b1f178f6in as well. Basically, this commit andb22b1f178f6should appear in the same stable release.
Ok, I've queued that one up as well.
thanks,
greg k-h
Re: [PATCH] thp: avoid atomic64_read in pmd_read_atomic for 32bit PAE\
In reply to Andrea ArcangeliQuoted 9 lines · Andrea Arcangeli
In the x86 32bit PAE
CONFIG_TRANSPARENT_HUGEPAGE=ycase while holding themmap_semfor reading, cmpxchg8b cannot be used to read pmd contents under Xen.So instead of dealing only with "consistent" pmdvals in
pmd_none_or_trans_huge_or_clear_bad()(which would be conceptually simpler) we letpmd_none_or_trans_huge_or_clear_bad()deal with pmdvals where the low 32bit and high 32bit could be inconsistent (to avoid having to use cmpxchg8b).
<nods>
Quoted 8 lines
The only guarantee we get from
pmd_read_atomicis that if the low part of the pmd was found null, the high part will be null too (so the pmd will be considered unstable). And if the low part of the pmd is found "stable" later, then it means the whole pmd was read atomically (because after a pmd is stable, neitherMADV_DONTNEEDnor page faults can alter it anymore, and we read the high part after the low part).
Quoted 5 lines
In the 32bit PAE x86 case, it is enough to read the low part of the pmdval atomically to declare the pmd as "stable" and that's true for THP and no THP, furthermore in the THP case we also have a
barrier()that will prevent any inconsistent pmdvals to be cached by a later re-read of the *pmd.
Nice. Andrew, any chane you could test this patch on the affected Xen hypervisors? Was it as easy to reproduce this on a RHEL5 (U1?) hypervisor or is it really only on Linode and Amazon EC2?
Quoted 86 lines
Signed-off-by Andrea Arcangeli <[email protected]>--- arch/x86/include/asm/pgtable-3level.h | 30 +++++++++++++++++------------- include/asm-generic/pgtable.h | 10 ++++++++++ 2 files changed, 27 insertions(+), 13 deletions(-)arch/x86/include/asm/pgtable-3level.h +17
-13@@ -47,16 +47,26 @@ static inline void native_set_pte(pte_t *ptep, pte_t pte)* they can run pmd_offset_map_lock or pmd_trans_huge or other pmd * operations. * -* Without THP if the mmap_sem is hold for reading, the -* pmd can only transition from null to not null while pmd_read_atomic runs. -* So there's no need of literally reading it atomically. +* Without THP if the mmap_sem is hold for reading, the pmd can only +* transition from null to not null while pmd_read_atomic runs. So +* we can always return atomic pmd values with this function. * * With THP if the mmap_sem is hold for reading, the pmd can become -* THP or null or point to a pte (and in turn become "stable") at any -* time under pmd_read_atomic, so it's mandatory to read it atomically -* with cmpxchg8b. +* trans_huge or none or point to a pte (and in turn become "stable") +* at any time under pmd_read_atomic. We could read it really +* atomically here with a atomic64_read for the THP enabled case (and +* it would be a whole lot simpler), but to avoid using cmpxchg8b we +* only return an atomic pmdval if the low part of the pmdval is later +* found stable (i.e. pointing to a pte). And we're returning a none +* pmdval if the low part of the pmd is none. In some cases the high +* and low part of the pmdval returned may not be consistent if THP is +* enabled (the low part may point to previously mapped hugepage, +* while the high part may point to a more recently mapped hugepage), +* but pmd_none_or_trans_huge_or_clear_bad() only needs the low part +* of the pmd to be read atomically to decide if the pmd is unstable +* or not, with the only exception of when the low part of the pmd is +* zero in which case we return a none pmd. */ -#ifndef CONFIG_TRANSPARENT_HUGEPAGE static inline pmd_t pmd_read_atomic (pmd_t *pmdp) {pmdval_t ret;@@ -74,12 +84,6 @@ static inline pmd_t pmd_read_atomic(pmd_t *pmdp)return (pmd_t ) { ret }; } -#else /* CONFIG_TRANSPARENT_HUGEPAGE */ -static inline pmd_t pmd_read_atomic (pmd_t *pmdp) -{ -return (pmd_t ) {atomic64_read ((atomic64_t *)pmdp) }; -} -#endif /* CONFIG_TRANSPARENT_HUGEPAGE */ static inline void native_set_pte_atomic (pte_t *ptep,pte_t pte) {include/asm-generic/pgtable.h +10
-1@@ -484,6 +484,16 @@ static inline int pmd_none_or_trans_huge_or_clear_bad(pmd_t *pmd)/* * The barrier will stabilize the pmdval in a register or on * the stack so that it will stop changing under the code. +* +* When CONFIG_TRANSPARENT_HUGEPAGE=y on x86 32bit PAE, +* pmd_read_atomic is allowed to return a not atomic pmdval +* (for example pointing to an hugepage that has never been +* mapped in the pmd). The below checks will only care about +* the low part of the pmd with 32bit PAE x86 anyway, with the +* exception of pmd_none(). So the important thing is that if +* the low part of the pmd is found null, the high part will +* be also null or the pmd_none() check below would be +* confused. */ #ifdef CONFIG_TRANSPARENT_HUGEPAGE barrier (); --To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [Xen-devel] [PATCH] thp: avoid atomic64_read in pmd_read_atomic for 32bit PAE\
----- Original Message -----
Quoted 35 lines · Andrea Arcangeli
Quoted 11 lines
In the x86 32bit PAE
CONFIG_TRANSPARENT_HUGEPAGE=ycase while holding
themmap_semfor reading, cmpxchg8b cannot be used to read pmd contents under Xen.So instead of dealing only with "consistent" pmdvals in
pmd_none_or_trans_huge_or_clear_bad()(which would be conceptually simpler) we letpmd_none_or_trans_huge_or_clear_bad()deal with pmdvals
where the low 32bit and high 32bit could be inconsistent (to avoid having to use cmpxchg8b).<nods>
Quoted 13 lines
The only guarantee we get from
pmd_read_atomicis that if the low part
of the pmd was found null, the high part will be null too (so the pmd
will be considered unstable). And if the low part of the pmd is found
"stable" later, then it means the whole pmd was read atomically (because after a pmd is stable, neitherMADV_DONTNEEDnor page faults
can alter it anymore, and we read the high part after the low part).Quoted 7 lines
In the 32bit PAE x86 case, it is enough to read the low part of the pmdval atomically to declare the pmd as "stable" and that's true for
THP and no THP, furthermore in the THP case we also have abarrier()
that will prevent any inconsistent pmdvals to be cached by a later re-read of the *pmd.
Quoted 4 lines
Nice. Andrew, any chane you could test this patch on the affected Xen hypervisors? Was it as easy to reproduce this on a RHEL5 (U1?) hypervisor or is it really only on Linode and Amazon EC2?
Originally, I was able to reproduce the issue easily with a RHEL5 host. Now, with this patch it's fixed.
Drew
Re: [Xen-devel] [PATCH] thp: avoid atomic64_read in pmd_read_atomic for 32bit PAE\
Quoted 7 lines
Quoted 4 lines
Nice. Andrew, any chane you could test this patch on the affected Xen hypervisors? Was it as easy to reproduce this on a RHEL5 (U1?) hypervisor or is it really only on Linode and Amazon EC2?
Originally, I was able to reproduce the issue easily with a RHEL5 host. Now, with this patch it's fixed.
OK, so Tested-by: Andrew Jones..
and from my perspective it looks good - so Acked-by: Konrad Rzeszutek Wilk <[email protected]>
Andrea, any chance you can respin this patch and send it to Linus for 3.5 please?
Re: [Xen-devel] [PATCH] thp: avoid atomic64_read in pmd_read_atomic for 32bit PAE\
Hi,
Quoted 10 lines · Konrad Rzeszutek Wilk
Quoted 7 lines
Quoted 4 lines
Nice. Andrew, any chane you could test this patch on the affected Xen hypervisors? Was it as easy to reproduce this on a RHEL5 (U1?) hypervisor or is it really only on Linode and Amazon EC2?
Originally, I was able to reproduce the issue easily with a RHEL5 host. Now, with this patch it's fixed.
OK, so Tested-by: Andrew Jones..
and from my perspective it looks good - so Acked-by: Konrad Rzeszutek Wilk <[email protected]>
Thanks for testing and reviews.
Quoted 1 line
Andrea, any chance you can respin this patch and send it to Linus for 3.5 please?
Andrew merged it in -mm last Friday, so I would expect it to go upstream soon through the -mm flow (I assume everyone has been rightfully waiting a bit of time for testing and reviews to be sure).
Andrea