Bug 198360 - ARMv6 L1 table overflow @ locore-v6.S
Summary: ARMv6 L1 table overflow @ locore-v6.S
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: arm (show other bugs)
Version: CURRENT
Hardware: arm Any
: --- Affects Some People
Assignee: freebsd-arm (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-03-06 16:15 UTC by aoyama
Modified: 2015-11-28 14:29 UTC (History)
1 user (show)

See Also:


Attachments
locore-v6.diff (392 bytes, patch)
2015-03-06 16:15 UTC, aoyama
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description aoyama 2015-03-06 16:15:04 UTC
Created attachment 153912 [details]
locore-v6.diff

If define SOCDEV_PA/SOCDEV_VA and VA is located at last 63pages, build_pagetables break after L1 table.
As a result kernel symbol is broken, and the kernel will crash.

L1 table is overflow by r3 is passed as fixed 64 pages.

/usr/src/sys/arm/arm/locore-v6.S
    128         /* Map 64MiB, preserved over calls to build_pagetables */
    129         mov     r3, #64

    137 #if defined(SOCDEV_PA) && defined(SOCDEV_VA)
    138         /* Create the custom map used for early_printf(). */
    139         ldr     r1, =SOCDEV_PA
    140         ldr     r2, =SOCDEV_VA
    141         bl      build_pagetables
    142 #endif

    342 build_pagetables:

    356         mov     r4, r3
    357 1:
    358         str     r1, [r0, r2]
    359         add     r2, r2, #4
    360         add     r1, r1, #(PTE1_SIZE)
    361         adds    r4, r4, #-1
    362         bhi     1b

Attached patch stop at end of L1 table.
Comment 1 commit-hook freebsd_committer freebsd_triage 2015-11-10 11:46:24 UTC
A commit references this bug:

Author: mmel
Date: Tue Nov 10 11:45:42 UTC 2015
New revision: 290647
URL: https://svnweb.freebsd.org/changeset/base/290647

Log:
  ARM: Improve robustness of locore_v6.S and fix errors.
  - boot page table is not allocated in data section, so must be
    cleared before use
  - map only one section (1 MB) for SOCDEV mapping (*)
  - DSB must be used for ensuring of finishing TLB operations
  - Invalidate BTB when appropriate

  PR:		198360
  Reported by:	Daisuke Aoyama <aoyama at peach.ne.jp> (*)
  Approved by:	kib (mentor)

Changes:
  head/sys/arm/arm/locore-v6.S
Comment 2 Michael Moll freebsd_committer freebsd_triage 2015-11-28 14:29:57 UTC
closing with mmel@'s blessings.