Changeset 30796


Ignore:
Timestamp:
Oct 21, 2016, 2:57:59 PM (7 months ago)
Author:
brainslayer
Message:

kernel update

Location:
src/linux/universal/linux-4.4
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • src/linux/universal/linux-4.4/arch/x86/boot/compressed/Makefile

    r28606 r30796  
    2323
    2424KBUILD_CFLAGS := -m$(BITS) -D__KERNEL__ $(LINUX_INCLUDE) -O2
    25 KBUILD_CFLAGS += -fno-strict-aliasing -fPIC
     25KBUILD_CFLAGS += -fno-strict-aliasing $(call cc-option, -fPIE, -fPIC)
    2626KBUILD_CFLAGS += -DDISABLE_BRANCH_PROFILING
    2727cflags-$(CONFIG_X86_32) := -march=i386
     
    3636
    3737LDFLAGS := -m elf_$(UTS_MACHINE)
     38ifeq ($(CONFIG_RELOCATABLE),y)
     39# If kernel is relocatable, build compressed kernel as PIE.
     40ifeq ($(CONFIG_X86_32),y)
     41LDFLAGS += $(call ld-option, -pie) $(call ld-option, --no-dynamic-linker)
     42else
     43# To build 64-bit compressed kernel as PIE, we disable relocation
     44# overflow check to avoid relocation overflow error with a new linker
     45# command-line option, -z noreloc-overflow.
     46LDFLAGS += $(shell $(LD) --help 2>&1 | grep -q "\-z noreloc-overflow" \
     47        && echo "-z noreloc-overflow -pie --no-dynamic-linker")
     48endif
     49endif
    3850LDFLAGS_vmlinux := -T
    3951
  • src/linux/universal/linux-4.4/arch/x86/boot/compressed/head_32.S

    r28606 r30796  
    3131#include <asm/asm-offsets.h>
    3232#include <asm/bootparam.h>
     33
     34/*
     35 * The 32-bit x86 assembler in binutils 2.26 will generate R_386_GOT32X
     36 * relocation to get the symbol address in PIC.  When the compressed x86
     37 * kernel isn't built as PIC, the linker optimizes R_386_GOT32X
     38 * relocations to their fixed symbol addresses.  However, when the
     39 * compressed x86 kernel is loaded at a different address, it leads
     40 * to the following load failure:
     41 *
     42 *   Failed to allocate space for phdrs
     43 *
     44 * during the decompression stage.
     45 *
     46 * If the compressed x86 kernel is relocatable at run-time, it should be
     47 * compiled with -fPIE, instead of -fPIC, if possible and should be built as
     48 * Position Independent Executable (PIE) so that linker won't optimize
     49 * R_386_GOT32X relocation to its fixed symbol address.  Older
     50 * linkers generate R_386_32 relocations against locally defined symbols,
     51 * _bss, _ebss, _got and _egot, in PIE.  It isn't wrong, just less
     52 * optimal than R_386_RELATIVE.  But the x86 kernel fails to properly handle
     53 * R_386_32 relocations when relocating the kernel.  To generate
     54 * R_386_RELATIVE relocations, we mark _bss, _ebss, _got and _egot as
     55 * hidden:
     56 */
     57        .hidden _bss
     58        .hidden _ebss
     59        .hidden _got
     60        .hidden _egot
    3361
    3462        __HEAD
  • src/linux/universal/linux-4.4/arch/x86/boot/compressed/head_64.S

    r28606 r30796  
    3333#include <asm/asm-offsets.h>
    3434#include <asm/bootparam.h>
     35
     36/*
     37 * Locally defined symbols should be marked hidden:
     38 */
     39        .hidden _bss
     40        .hidden _ebss
     41        .hidden _got
     42        .hidden _egot
    3543
    3644        __HEAD
  • src/linux/universal/linux-4.4/include/linux/mm.h

    r30691 r30796  
    21142114#define FOLL_TRIED      0x800   /* a retry, previous pass started an IO */
    21152115#define FOLL_MLOCK      0x1000  /* lock present pages */
     2116#define FOLL_COW        0x4000  /* internal GUP flag */
    21162117
    21172118typedef int (*pte_fn_t)(pte_t *pte, pgtable_t token, unsigned long addr,
  • src/linux/universal/linux-4.4/mm/gup.c

    r28606 r30796  
    5757        /* Proper page table entry exists, but no corresponding struct page */
    5858        return -EEXIST;
     59}
     60
     61/*
     62 * FOLL_FORCE can write to even unwritable pte's, but only
     63 * after we've gone through a COW cycle and they are dirty.
     64 */
     65static inline bool can_follow_write_pte(pte_t pte, unsigned int flags)
     66{
     67        return pte_write(pte) ||
     68                ((flags & FOLL_FORCE) && (flags & FOLL_COW) && pte_dirty(pte));
    5969}
    6070
     
    93103        if ((flags & FOLL_NUMA) && pte_protnone(pte))
    94104                goto no_page;
    95         if ((flags & FOLL_WRITE) && !pte_write(pte)) {
     105        if ((flags & FOLL_WRITE) && !can_follow_write_pte(pte, flags)) {
    96106                pte_unmap_unlock(ptep, ptl);
    97107                return NULL;
     
    353363         */
    354364        if ((ret & VM_FAULT_WRITE) && !(vma->vm_flags & VM_WRITE))
    355                 *flags &= ~FOLL_WRITE;
     365                *flags |= FOLL_COW;
    356366        return 0;
    357367}
Note: See TracChangeset for help on using the changeset viewer.