1. 10 5月, 2016 1 次提交
    • C
      kvm: arm64: Enable hardware updates of the Access Flag for Stage 2 page tables · 06485053
      Catalin Marinas 提交于
      The ARMv8.1 architecture extensions introduce support for hardware
      updates of the access and dirty information in page table entries. With
      VTCR_EL2.HA enabled (bit 21), when the CPU accesses an IPA with the
      PTE_AF bit cleared in the stage 2 page table, instead of raising an
      Access Flag fault to EL2 the CPU sets the actual page table entry bit
      (10). To ensure that kernel modifications to the page table do not
      inadvertently revert a bit set by hardware updates, certain Stage 2
      software pte/pmd operations must be performed atomically.
      
      The main user of the AF bit is the kvm_age_hva() mechanism. The
      kvm_age_hva_handler() function performs a "test and clear young" action
      on the pte/pmd. This needs to be atomic in respect of automatic hardware
      updates of the AF bit. Since the AF bit is in the same position for both
      Stage 1 and Stage 2, the patch reuses the existing
      ptep_test_and_clear_young() functionality if
      __HAVE_ARCH_PTEP_TEST_AND_CLEAR_YOUNG is defined. Otherwise, the
      existing pte_young/pte_mkold mechanism is preserved.
      
      The kvm_set_s2pte_readonly() (and the corresponding pmd equivalent) have
      to perform atomic modifications in order to avoid a race with updates of
      the AF bit. The arm64 implementation has been re-written using
      exclusives.
      
      Currently, kvm_set_s2pte_writable() (and pmd equivalent) take a pointer
      argument and modify the pte/pmd in place. However, these functions are
      only used on local variables rather than actual page table entries, so
      it makes more sense to follow the pte_mkwrite() approach for stage 1
      attributes. The change to kvm_s2pte_mkwrite() makes it clear that these
      functions do not modify the actual page table entries.
      
      The (pte|pmd)_mkyoung() uses on Stage 2 entries (setting the AF bit
      explicitly) do not need to be modified since hardware updates of the
      dirty status are not supported by KVM, so there is no possibility of
      losing such information.
      Signed-off-by: NCatalin Marinas <catalin.marinas@arm.com>
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Acked-by: NMarc Zyngier <marc.zyngier@arm.com>
      Reviewed-by: NChristoffer Dall <christoffer.dall@linaro.org>
      Signed-off-by: NChristoffer Dall <christoffer.dall@linaro.org>
      06485053
  2. 21 4月, 2016 5 次提交
  3. 08 4月, 2016 1 次提交
  4. 26 3月, 2016 1 次提交
  5. 21 3月, 2016 1 次提交
  6. 14 3月, 2016 2 次提交
    • A
      ipv6: Pass proto to csum_ipv6_magic as __u8 instead of unsigned short · 1e940829
      Alexander Duyck 提交于
      This patch updates csum_ipv6_magic so that it correctly recognizes that
      protocol is a unsigned 8 bit value.
      
      This will allow us to better understand what limitations may or may not be
      present in how we handle the data.  For example there are a number of
      places that call htonl on the protocol value.  This is likely not necessary
      and can be replaced with a multiplication by ntohl(1) which will be
      converted to a shift by the compiler.
      Signed-off-by: NAlexander Duyck <aduyck@mirantis.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      1e940829
    • A
      ipv4: Update parameters for csum_tcpudp_magic to their original types · 01cfbad7
      Alexander Duyck 提交于
      This patch updates all instances of csum_tcpudp_magic and
      csum_tcpudp_nofold to reflect the types that are usually used as the source
      inputs.  For example the protocol field is populated based on nexthdr which
      is actually an unsigned 8 bit value.  The length is usually populated based
      on skb->len which is an unsigned integer.
      
      This addresses an issue in which the IPv6 function csum_ipv6_magic was
      generating a checksum using the full 32b of skb->len while
      csum_tcpudp_magic was only using the lower 16 bits.  As a result we could
      run into issues when attempting to adjust the checksum as there was no
      protocol agnostic way to update it.
      
      With this change the value is still truncated as many architectures use
      "(len + proto) << 8", however this truncation only occurs for values
      greater than 16776960 in length and as such is unlikely to occur as we stop
      the inner headers at ~64K in size.
      
      I did have to make a few minor changes in the arm, mn10300, nios2, and
      score versions of the function in order to support these changes as they
      were either using things such as an OR to combine the protocol and length,
      or were using ntohs to convert the length which would have truncated the
      value.
      
      I also updated a few spots in terms of whitespace and type differences for
      the addresses.  Most of this was just to make sure all of the definitions
      were in sync going forward.
      Signed-off-by: NAlexander Duyck <aduyck@mirantis.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      01cfbad7
  7. 08 3月, 2016 1 次提交
  8. 01 3月, 2016 16 次提交
  9. 26 2月, 2016 1 次提交
  10. 23 2月, 2016 2 次提交
    • A
      ARM: 8531/1: turn init_new_context into an inline function · 7d74a5f0
      Arnd Bergmann 提交于
      Almost all architectures define init_new_context() as a function,
      but on ARM, it's a macro and that causes a compiler warning when
      its return code is not used:
      
      drivers/firmware/efi/arm-runtime.c: In function 'efi_virtmap_init':
      arch/arm/include/asm/mmu_context.h:88:34: warning: statement with no effect [-Wunused-value]
       #define init_new_context(tsk,mm) 0
      drivers/firmware/efi/arm-runtime.c:47:2: note: in expansion of macro 'init_new_context'
        init_new_context(NULL, &efi_mm);
      
      This changes the definition into an inline function, which gcc does
      not warn about.
      Signed-off-by: NArnd Bergmann <arnd@arndb.de>
      Signed-off-by: NRussell King <rmk+kernel@arm.linux.org.uk>
      7d74a5f0
    • A
      ARM: 8530/1: remove VIRT_TO_BUS · 9e0087e6
      Arnd Bergmann 提交于
      All drivers that are relevant for rpc or footbridge have stopped
      using virt_to_bus a while ago, so we can remove it and avoid some
      harmless randconfig warnings for drivers that we do not care about:
      
      drivers/atm/zatm.c: In function 'poll_rx':
      drivers/atm/zatm.c:401:18: warning: 'bus_to_virt' is deprecated [-Wdeprecated-declarations]
         skb = ((struct rx_buffer_head *) bus_to_virt(here[2]))->skb;
      
      FWIW, the remaining drivers using this are:
      
      ATM:  firestream, zatm, ambassador, horizon
      ISDN: hisax/netjet
      V4L:  STA2X11, zoran
      Net:  Appletalk LTPC, Tulip DE4x5, Toshiba IrDA
      WAN:  comtrol sv11, cosa, lanmedia, sealevel
      SCSI: DPT_I2O, buslogic
      VME:  CA91C142
      
      My best guess is that all of the above are so hopelessly obsolete that
      we are best off removing all of them form the kernel, but that can be
      done another time.
      Signed-off-by: NArnd Bergmann <arnd@arndb.de>
      Signed-off-by: NRussell King <rmk+kernel@arm.linux.org.uk>
      9e0087e6
  11. 22 2月, 2016 1 次提交
    • K
      asm-generic: Consolidate mark_rodata_ro() · e267d97b
      Kees Cook 提交于
      Instead of defining mark_rodata_ro() in each architecture, consolidate it.
      Signed-off-by: NKees Cook <keescook@chromium.org>
      Acked-by: NWill Deacon <will.deacon@arm.com>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Andy Gross <agross@codeaurora.org>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Ashok Kumar <ashoks@broadcom.com>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Borislav Petkov <bp@suse.de>
      Cc: Brian Gerst <brgerst@gmail.com>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Dan Williams <dan.j.williams@intel.com>
      Cc: David Brown <david.brown@linaro.org>
      Cc: David Hildenbrand <dahi@linux.vnet.ibm.com>
      Cc: Denys Vlasenko <dvlasenk@redhat.com>
      Cc: Emese Revfy <re.emese@gmail.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Helge Deller <deller@gmx.de>
      Cc: James E.J. Bottomley <jejb@parisc-linux.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Luis R. Rodriguez <mcgrof@suse.com>
      Cc: Marc Zyngier <marc.zyngier@arm.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Mathias Krause <minipli@googlemail.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Nicolas Pitre <nicolas.pitre@linaro.org>
      Cc: PaX Team <pageexec@freemail.hu>
      Cc: Paul Gortmaker <paul.gortmaker@windriver.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Ross Zwisler <ross.zwisler@linux.intel.com>
      Cc: Russell King <linux@arm.linux.org.uk>
      Cc: Rusty Russell <rusty@rustcorp.com.au>
      Cc: Stephen Boyd <sboyd@codeaurora.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Toshi Kani <toshi.kani@hp.com>
      Cc: kernel-hardening@lists.openwall.com
      Cc: linux-arch <linux-arch@vger.kernel.org>
      Cc: linux-arm-kernel@lists.infradead.org
      Cc: linux-kernel@vger.kernel.org
      Cc: linux-parisc@vger.kernel.org
      Link: http://lkml.kernel.org/r/1455748879-21872-2-git-send-email-keescook@chromium.orgSigned-off-by: NIngo Molnar <mingo@kernel.org>
      e267d97b
  12. 19 2月, 2016 2 次提交
  13. 17 2月, 2016 3 次提交
    • R
      ARM: make the physical-relative calculation more obvious · 8ff97fa3
      Russell King 提交于
      The physical-relative calculation between the XIP text and data sections
      introduced by the previous patch was far from obvious. Let's simplify it
      by turning it into a macro which takes the two (virtual) addresses.
      
      This allows us to arrange the calculation in a more obvious manner - we
      can make it two sub-expressions which calculate the physical address for
      each symbol, and then takes the difference of those physical addresses.
      Signed-off-by: NRussell King <rmk+kernel@arm.linux.org.uk>
      8ff97fa3
    • N
      ARM: 8512/1: proc-v7.S: Adjust stack address when XIP_KERNEL · d7811455
      Nicolas Pitre 提交于
      When XIP_KERNEL is enabled, the virt to phys address translation for RAM
      is not the same as the virt to phys address translation for .text.
      The only way to know where physical RAM is located is to use
      PLAT_PHYS_OFFSET.
      The MACRO will be useful for other places where there is a similar problem.
      Signed-off-by: NNicolas Pitre <nico@linaro.org>
      Signed-off-by: NChris Brandt <chris.brandt@renesas.com>
      Signed-off-by: NRussell King <rmk+kernel@arm.linux.org.uk>
      d7811455
    • K
      ARM: 8411/1: Add default SPARSEMEM settings · db57f88e
      Kevin Cernekee 提交于
      We can still override these settings via mach/memory.h, but let's provide
      sensible defaults so that SPARSEMEM is available in the multiplatform
      kernels.
      
      Two platforms currently use SECTION_SIZE_BITS < 28, but are expected to
      work with 28 (albeit slightly less efficiently if not all banks are
      populated):
      
       - mach-rpc: uses 26 bits.  Based on mach/hardware.h it looks like this
         platform puts RAM at 0x1000_0000 - 0x1fff_ffff, and I/O below
         0x1000_0000.
      
       - mach-sa1100: uses 27 bits.  mach/memory.h indicates that RAM occupies
         the entire range of 0xc000_0000 - 0xdfff_ffff.
      
      But Arnd says in that rpc and sa1100 will never have to use the
      default since they cannot be part of a multiplatform kernel, and that
      is unlikely to change.
      
      Several platforms need MAX_PHYSMEM_BITS >= 36 so we'll pick that as the
      minimum.  Anything higher and we'll fail the SECTIONS_WIDTH + NODES_WIDTH +
      ZONES_WIDTH test in <linux/mm.h>.
      
      Some analysis from Russell King at
      http://lists.infradead.org/pipermail/linux-arm-kernel/2014-October/298957.html:
      
        I think this is fine in as far as it goes - this means we end up with
        256 entries in the mem_section array which means it occupies one page,
        which I think is acceptable overhead.
      
        The other thing to be aware of here is the obvious:
      
        #if (MAX_ORDER - 1 + PAGE_SHIFT) > SECTION_SIZE_BITS
        #error Allocator MAX_ORDER exceeds SECTION_SIZE
        #endif
      
        Which means that with 28 bits of section, that's a maximum allocator
        order of 16.  We appear to allow FORCE_MAX_ZONEORDER to be set up to
        64 in the case of shmobile, which doesn't seem like a sensible upper
        limit - and certainly isn't when sparsemem is enabled.
      
        Given this, I think that FORCE_MAX_ZONEORDER's help, and the
        dependencies probably could do with some improvement to make the
        issues more transparent.
      
      [gregory.0xf0: added notes from Arnd and Russell]
      Signed-off-by: NKevin Cernekee <cernekee@gmail.com>
      Acked-by: NArnd Bergmann <arnd@arndb.de>
      Tested-by: NStephen Boyd <sboyd@codeaurora.org>
      Signed-off-by: NGregory Fong <gregory.0xf0@gmail.com>
      Signed-off-by: NRussell King <rmk+kernel@arm.linux.org.uk>
      db57f88e
  14. 11 2月, 2016 2 次提交
    • C
      ARM: 8518/1: Use correct symbols for XIP_KERNEL · 02afa9a8
      Chris Brandt 提交于
      For an XIP build, _etext does not represent the end of the
      binary image that needs to stay mapped into the MODULES_VADDR area.
      Years ago, data came before text in the memory map. However,
      now that the order is text/init/data, an XIP_KERNEL needs to map
      up to the data location in order to keep from cutting off
      parts of the kernel that are needed.
      We only map up to the beginning of data because data has already been
      copied, so there's no reason to keep it around anymore.
      A new symbol is created to make it clear what it is we are referring
      to.
      
      This fixes the bug where you might lose the end of your kernel area
      after page table setup is complete.
      Signed-off-by: NChris Brandt <chris.brandt@renesas.com>
      Signed-off-by: NRussell King <rmk+kernel@arm.linux.org.uk>
      02afa9a8
    • N
      ARM: 8504/1: __arch_xprod_64(): small optimization · 73e592f3
      Nicolas Pitre 提交于
      The tmp variable is used twice: first to pose as a register containing
      a value of zero, and then to provide a temporary register that initially
      is zero and get added some value. But somehow gcc decides to split those
      two usages in different registers.
      
      Example code:
      
      u64 div64const1000(u64 x)
      {
      	u32 y = 1000;
      	do_div(x, y);
      	return x;
      }
      
      Result:
      
      div64const1000:
      	push	{r4, r5, r6, r7, lr}
      	mov	lr, #0
      	mov	r6, r0
      	mov	r7, r1
      	adr	r5, .L8
      	ldrd	r4, [r5]
      	mov	r1, lr
      	umull	r2, r3, r4, r6
      	cmn	r2, r4
      	adcs	r3, r3, r5
      	adc	r2, lr, #0
      	umlal	r3, r2, r5, r6
      	umlal	r3, r1, r4, r7
      	mov	r3, #0
      	adds	r2, r1, r2
      	adc	r3, r3, #0
      	umlal	r2, r3, r5, r7
      	lsr	r0, r2, #9
      	lsr	r1, r3, #9
      	orr	r0, r0, r3, lsl #23
      	pop	{r4, r5, r6, r7, pc}
      	.align	3
      .L8:
      	.word	-1924145349
      	.word	-2095944041
      
      Full kernel build size:
      
         text	   data	    bss	    dec	    hex	filename
      13663814	1553940	 351368	15569122	 ed90e2	vmlinux
      
      Here the two instances of 'tmp' are assigned to r1 and lr.
      
      To avoid that, let's mark the first 'tmp' usage in __arch_xprod_64()
      with a "+r" constraint even if the register is not written to, so to
      create a dependency for the second usage with the effect of enforcing
      a single temporary register throughout.
      
      Result:
      
      div64const1000:
      	push	{r4, r5, r6, r7}
      	movs	r3, #0
      	adr	r5, .L8
      	ldrd	r4, [r5]
      	umull	r6, r7, r4, r0
      	cmn	r6, r4
      	adcs	r7, r7, r5
      	adc	r6, r3, #0
      	umlal	r7, r6, r5, r0
      	umlal	r7, r3, r4, r1
      	mov	r7, #0
      	adds	r6, r3, r6
      	adc	r7, r7, #0
      	umlal	r6, r7, r5, r1
      	lsr	r0, r6, #9
      	lsr	r1, r7, #9
      	orr	r0, r0, r7, lsl #23
      	pop	{r4, r5, r6, r7}
      	bx	lr
      	.align	3
      .L8:
      	.word	-1924145349
      	.word	-2095944041
      
         text	   data	    bss	    dec	    hex	filename
      13663438	1553940	 351368	15568746	 ed8f6a	vmlinux
      
      This time 'tmp' is assigned to r3 and used throughout. However, by being
      assigned to r3, that blocks usage of the r2-r3 double register slot for
      64-bit values, forcing more registers to be spilled on the stack. Let's
      try to help it by forcing 'tmp' to the caller-saved ip register.
      
      Result:
      
      div64const1000:
      	stmfd	sp!, {r4, r5}
      	mov	ip, #0
      	adr	r5, .L8
      	ldrd	r4, [r5]
      	umull	r2, r3, r4, r0
      	cmn	r2, r4
      	adcs	r3, r3, r5
      	adc	r2, ip, #0
      	umlal	r3, r2, r5, r0
      	umlal	r3, ip, r4, r1
      	mov	r3, #0
      	adds	r2, ip, r2
      	adc	r3, r3, #0
      	umlal	r2, r3, r5, r1
      	mov	r0, r2, lsr #9
      	mov	r1, r3, lsr #9
      	orr	r0, r0, r3, asl #23
      	ldmfd	sp!, {r4, r5}
      	bx	lr
      	.align	3
      .L8:
      	.word	-1924145349
      	.word	-2095944041
      
         text	   data	    bss	    dec	    hex	filename
      13662838	1553940	 351368	15568146	 ed8d12	vmlinux
      
      We could make the code marginally smaller yet by forcing 'tmp' to lr
      instead, but that would have a negative inpact on branch prediction for
      which "bx lr" is optimal.
      Signed-off-by: NNicolas Pitre <nico@linaro.org>
      Signed-off-by: NRussell King <rmk+kernel@arm.linux.org.uk>
      73e592f3
  15. 10 2月, 2016 1 次提交