kernel_optimize_test/arch/m32r/mm/mmu.S
Greg Kroah-Hartman b24413180f License cleanup: add SPDX GPL-2.0 license identifier to files with no license
Many source files in the tree are missing licensing information, which
makes it harder for compliance tools to determine the correct license.

By default all files without license information are under the default
license of the kernel, which is GPL version 2.

Update the files which contain no license information with the 'GPL-2.0'
SPDX license identifier.  The SPDX identifier is a legally binding
shorthand, which can be used instead of the full boiler plate text.

This patch is based on work done by Thomas Gleixner and Kate Stewart and
Philippe Ombredanne.

How this work was done:

Patches were generated and checked against linux-4.14-rc6 for a subset of
the use cases:
 - file had no licensing information it it.
 - file was a */uapi/* one with no licensing information in it,
 - file was a */uapi/* one with existing licensing information,

Further patches will be generated in subsequent months to fix up cases
where non-standard license headers were used, and references to license
had to be inferred by heuristics based on keywords.

The analysis to determine which SPDX License Identifier to be applied to
a file was done in a spreadsheet of side by side results from of the
output of two independent scanners (ScanCode & Windriver) producing SPDX
tag:value files created by Philippe Ombredanne.  Philippe prepared the
base worksheet, and did an initial spot review of a few 1000 files.

The 4.13 kernel was the starting point of the analysis with 60,537 files
assessed.  Kate Stewart did a file by file comparison of the scanner
results in the spreadsheet to determine which SPDX license identifier(s)
to be applied to the file. She confirmed any determination that was not
immediately clear with lawyers working with the Linux Foundation.

Criteria used to select files for SPDX license identifier tagging was:
 - Files considered eligible had to be source code files.
 - Make and config files were included as candidates if they contained >5
   lines of source
 - File already had some variant of a license header in it (even if <5
   lines).

All documentation files were explicitly excluded.

The following heuristics were used to determine which SPDX license
identifiers to apply.

 - when both scanners couldn't find any license traces, file was
   considered to have no license information in it, and the top level
   COPYING file license applied.

   For non */uapi/* files that summary was:

   SPDX license identifier                            # files
   ---------------------------------------------------|-------
   GPL-2.0                                              11139

   and resulted in the first patch in this series.

   If that file was a */uapi/* path one, it was "GPL-2.0 WITH
   Linux-syscall-note" otherwise it was "GPL-2.0".  Results of that was:

   SPDX license identifier                            # files
   ---------------------------------------------------|-------
   GPL-2.0 WITH Linux-syscall-note                        930

   and resulted in the second patch in this series.

 - if a file had some form of licensing information in it, and was one
   of the */uapi/* ones, it was denoted with the Linux-syscall-note if
   any GPL family license was found in the file or had no licensing in
   it (per prior point).  Results summary:

   SPDX license identifier                            # files
   ---------------------------------------------------|------
   GPL-2.0 WITH Linux-syscall-note                       270
   GPL-2.0+ WITH Linux-syscall-note                      169
   ((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause)    21
   ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause)    17
   LGPL-2.1+ WITH Linux-syscall-note                      15
   GPL-1.0+ WITH Linux-syscall-note                       14
   ((GPL-2.0+ WITH Linux-syscall-note) OR BSD-3-Clause)    5
   LGPL-2.0+ WITH Linux-syscall-note                       4
   LGPL-2.1 WITH Linux-syscall-note                        3
   ((GPL-2.0 WITH Linux-syscall-note) OR MIT)              3
   ((GPL-2.0 WITH Linux-syscall-note) AND MIT)             1

   and that resulted in the third patch in this series.

 - when the two scanners agreed on the detected license(s), that became
   the concluded license(s).

 - when there was disagreement between the two scanners (one detected a
   license but the other didn't, or they both detected different
   licenses) a manual inspection of the file occurred.

 - In most cases a manual inspection of the information in the file
   resulted in a clear resolution of the license that should apply (and
   which scanner probably needed to revisit its heuristics).

 - When it was not immediately clear, the license identifier was
   confirmed with lawyers working with the Linux Foundation.

 - If there was any question as to the appropriate license identifier,
   the file was flagged for further research and to be revisited later
   in time.

In total, over 70 hours of logged manual review was done on the
spreadsheet to determine the SPDX license identifiers to apply to the
source files by Kate, Philippe, Thomas and, in some cases, confirmation
by lawyers working with the Linux Foundation.

Kate also obtained a third independent scan of the 4.13 code base from
FOSSology, and compared selected files where the other two scanners
disagreed against that SPDX file, to see if there was new insights.  The
Windriver scanner is based on an older version of FOSSology in part, so
they are related.

Thomas did random spot checks in about 500 files from the spreadsheets
for the uapi headers and agreed with SPDX license identifier in the
files he inspected. For the non-uapi files Thomas did random spot checks
in about 15000 files.

In initial set of patches against 4.14-rc6, 3 files were found to have
copy/paste license identifier errors, and have been fixed to reflect the
correct identifier.

Additionally Philippe spent 10 hours this week doing a detailed manual
inspection and review of the 12,461 patched files from the initial patch
version early this week with:
 - a full scancode scan run, collecting the matched texts, detected
   license ids and scores
 - reviewing anything where there was a license detected (about 500+
   files) to ensure that the applied SPDX license was correct
 - reviewing anything where there was no detection but the patch license
   was not GPL-2.0 WITH Linux-syscall-note to ensure that the applied
   SPDX license was correct

This produced a worksheet with 20 files needing minor correction.  This
worksheet was then exported into 3 different .csv files for the
different types of files to be modified.

These .csv files were then reviewed by Greg.  Thomas wrote a script to
parse the csv files and add the proper SPDX tag to the file, in the
format that the file expected.  This script was further refined by Greg
based on the output to detect more types of files automatically and to
distinguish between header and source .c files (which need different
comment types.)  Finally Greg ran the script using the .csv files to
generate the patches.

Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
Reviewed-by: Philippe Ombredanne <pombredanne@nexb.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-02 11:10:55 +01:00

356 lines
7.1 KiB
ArmAsm

/* SPDX-License-Identifier: GPL-2.0 */
/*
* linux/arch/m32r/mm/mmu.S
*
* Copyright (C) 2001 by Hiroyuki Kondo
*/
#include <linux/linkage.h>
#include <asm/assembler.h>
#include <asm/smp.h>
.text
#ifdef CONFIG_MMU
#include <asm/mmu_context.h>
#include <asm/page.h>
#include <asm/pgtable.h>
#include <asm/m32r.h>
/*
* TLB Miss Exception handler
*/
.balign 16
ENTRY(tme_handler)
.global tlb_entry_i_dat
.global tlb_entry_d_dat
SWITCH_TO_KERNEL_STACK
#if defined(CONFIG_ISA_M32R2)
st r0, @-sp
st r1, @-sp
st r2, @-sp
st r3, @-sp
seth r3, #high(MMU_REG_BASE)
ld r1, @(MESTS_offset, r3) ; r1: status (MESTS reg.)
ld r0, @(MDEVP_offset, r3) ; r0: PFN + ASID (MDEVP reg.)
st r1, @(MESTS_offset, r3) ; clear status (MESTS reg.)
and3 r1, r1, #(MESTS_IT)
bnez r1, 1f ; instruction TLB miss?
;; data TLB miss
;; input
;; r0: PFN + ASID (MDEVP reg.)
;; r1 - r3: free
;; output
;; r0: PFN + ASID
;; r1: TLB entry base address
;; r2: &tlb_entry_{i|d}_dat
;; r3: free
#ifndef CONFIG_SMP
seth r2, #high(tlb_entry_d_dat)
or3 r2, r2, #low(tlb_entry_d_dat)
#else /* CONFIG_SMP */
ldi r1, #-8192
seth r2, #high(tlb_entry_d_dat)
or3 r2, r2, #low(tlb_entry_d_dat)
and r1, sp
ld r1, @(16, r1) ; current_thread_info->cpu
slli r1, #2
add r2, r1
#endif /* !CONFIG_SMP */
seth r1, #high(DTLB_BASE)
or3 r1, r1, #low(DTLB_BASE)
bra 2f
.balign 16
.fillinsn
1:
;; instrucntion TLB miss
;; input
;; r0: MDEVP reg. (included ASID)
;; r1 - r3: free
;; output
;; r0: PFN + ASID
;; r1: TLB entry base address
;; r2: &tlb_entry_{i|d}_dat
;; r3: free
ldi r3, #-4096
and3 r0, r0, #(MMU_CONTEXT_ASID_MASK)
mvfc r1, bpc
and r1, r3
or r0, r1 ; r0: PFN + ASID
#ifndef CONFIG_SMP
seth r2, #high(tlb_entry_i_dat)
or3 r2, r2, #low(tlb_entry_i_dat)
#else /* CONFIG_SMP */
ldi r1, #-8192
seth r2, #high(tlb_entry_i_dat)
or3 r2, r2, #low(tlb_entry_i_dat)
and r1, sp
ld r1, @(16, r1) ; current_thread_info->cpu
slli r1, #2
add r2, r1
#endif /* !CONFIG_SMP */
seth r1, #high(ITLB_BASE)
or3 r1, r1, #low(ITLB_BASE)
.fillinsn
2:
;; select TLB entry
;; input
;; r0: PFN + ASID
;; r1: TLB entry base address
;; r2: &tlb_entry_{i|d}_dat
;; r3: free
;; output
;; r0: PFN + ASID
;; r1: TLB entry address
;; r2, r3: free
#ifdef CONFIG_ISA_DUAL_ISSUE
ld r3, @r2 || srli r1, #3
#else
ld r3, @r2
srli r1, #3
#endif
add r1, r3
; tlb_entry_{d|i}_dat++;
addi r3, #1
and3 r3, r3, #(NR_TLB_ENTRIES - 1)
#ifdef CONFIG_ISA_DUAL_ISSUE
st r3, @r2 || slli r1, #3
#else
st r3, @r2
slli r1, #3
#endif
;; load pte
;; input
;; r0: PFN + ASID
;; r1: TLB entry address
;; r2, r3: free
;; output
;; r0: PFN + ASID
;; r1: TLB entry address
;; r2: pte_data
;; r3: free
; pgd = *(unsigned long *)MPTB;
ld24 r2, #(-MPTB - 1)
srl3 r3, r0, #22
#ifdef CONFIG_ISA_DUAL_ISSUE
not r2, r2 || slli r3, #2 ; r3: pgd offset
#else
not r2, r2
slli r3, #2
#endif
ld r2, @r2 ; r2: pgd base addr (MPTB reg.)
or r3, r2 ; r3: pmd addr
; pmd = pmd_offset(pgd, address);
ld r3, @r3 ; r3: pmd data
beqz r3, 3f ; pmd_none(*pmd) ?
and3 r2, r3, #0xfff
add3 r2, r2, #-355 ; _KERNPG_TABLE(=0x163)
bnez r2, 3f ; pmd_bad(*pmd) ?
ldi r2, #-4096
; pte = pte_offset(pmd, address);
and r2, r3 ; r2: pte base addr
srl3 r3, r0, #10
and3 r3, r3, #0xffc ; r3: pte offset
or r3, r2
seth r2, #0x8000
or r3, r2 ; r3: pte addr
; pte_data = (unsigned long)pte_val(*pte);
ld r2, @r3 ; r2: pte data
and3 r3, r2, #2 ; _PAGE_PRESENT(=2) check
beqz r3, 3f
.fillinsn
5:
;; set tlb
;; input
;; r0: PFN + ASID
;; r1: TLB entry address
;; r2: pte_data
;; r3: free
st r0, @r1 ; set_tlb_tag(entry++, address);
st r2, @+r1 ; set_tlb_data(entry, pte_data);
.fillinsn
6:
ld r3, @sp+
ld r2, @sp+
ld r1, @sp+
ld r0, @sp+
rte
.fillinsn
3:
;; error
;; input
;; r0: PFN + ASID
;; r1: TLB entry address
;; r2, r3: free
;; output
;; r0: PFN + ASID
;; r1: TLB entry address
;; r2: pte_data
;; r3: free
#ifdef CONFIG_ISA_DUAL_ISSUE
bra 5b || ldi r2, #2
#else
ldi r2, #2 ; r2: pte_data = 0 | _PAGE_PRESENT(=2)
bra 5b
#endif
#elif defined (CONFIG_ISA_M32R)
st sp, @-sp
st r0, @-sp
st r1, @-sp
st r2, @-sp
st r3, @-sp
st r4, @-sp
seth r3, #high(MMU_REG_BASE)
ld r0, @(MDEVA_offset,r3) ; r0: address (MDEVA reg.)
mvfc r2, bpc ; r2: bpc
ld r1, @(MESTS_offset,r3) ; r1: status (MESTS reg.)
st r1, @(MESTS_offset,r3) ; clear status (MESTS reg.)
and3 r1, r1, #(MESTS_IT)
beqz r1, 1f ; data TLB miss?
;; instrucntion TLB miss
mv r0, r2 ; address = bpc;
; entry = (unsigned long *)ITLB_BASE+tlb_entry_i*2;
seth r3, #shigh(tlb_entry_i_dat)
ld r4, @(low(tlb_entry_i_dat),r3)
sll3 r2, r4, #3
seth r1, #high(ITLB_BASE)
or3 r1, r1, #low(ITLB_BASE)
add r2, r1 ; r2: entry
addi r4, #1 ; tlb_entry_i++;
and3 r4, r4, #(NR_TLB_ENTRIES-1)
st r4, @(low(tlb_entry_i_dat),r3)
bra 2f
.fillinsn
1:
;; data TLB miss
; entry = (unsigned long *)DTLB_BASE+tlb_entry_d*2;
seth r3, #shigh(tlb_entry_d_dat)
ld r4, @(low(tlb_entry_d_dat),r3)
sll3 r2, r4, #3
seth r1, #high(DTLB_BASE)
or3 r1, r1, #low(DTLB_BASE)
add r2, r1 ; r2: entry
addi r4, #1 ; tlb_entry_d++;
and3 r4, r4, #(NR_TLB_ENTRIES-1)
st r4, @(low(tlb_entry_d_dat),r3)
.fillinsn
2:
;; load pte
; r0: address, r2: entry
; r1,r3,r4: (free)
; pgd = *(unsigned long *)MPTB;
ld24 r1, #(-MPTB-1)
not r1, r1
ld r1, @r1
srl3 r4, r0, #22
sll3 r3, r4, #2
add r3, r1 ; r3: pgd
; pmd = pmd_offset(pgd, address);
ld r1, @r3 ; r1: pmd
beqz r1, 3f ; pmd_none(*pmd) ?
;
and3 r1, r1, #0x3ff
ldi r4, #0x163 ; _KERNPG_TABLE(=0x163)
bne r1, r4, 3f ; pmd_bad(*pmd) ?
.fillinsn
4:
; pte = pte_offset(pmd, address);
ld r4, @r3 ; r4: pte
ldi r3, #-4096
and r4, r3
srl3 r3, r0, #10
and3 r3, r3, #0xffc
add r4, r3
seth r3, #0x8000
add r4, r3 ; r4: pte
; pte_data = (unsigned long)pte_val(*pte);
ld r1, @r4 ; r1: pte_data
and3 r3, r1, #2 ; _PAGE_PRESENT(=2) check
beqz r3, 3f
.fillinsn
;; set tlb
; r0: address, r1: pte_data, r2: entry
; r3,r4: (free)
5:
ldi r3, #-4096 ; set_tlb_tag(entry++, address);
and r3, r0
seth r4, #shigh(MASID)
ld r4, @(low(MASID),r4) ; r4: MASID
and3 r4, r4, #(MMU_CONTEXT_ASID_MASK)
or r3, r4
st r3, @r2
st r1, @(4,r2) ; set_tlb_data(entry, pte_data);
ld r4, @sp+
ld r3, @sp+
ld r2, @sp+
ld r1, @sp+
ld r0, @sp+
ld sp, @sp+
rte
.fillinsn
3:
ldi r1, #2 ; r1: pte_data = 0 | _PAGE_PRESENT(=2)
bra 5b
#else
#error unknown isa configuration
#endif
ENTRY(init_tlb)
;; Set MMU Register
seth r0, #high(MMU_REG_BASE) ; Set MMU_REG_BASE higher
or3 r0, r0, #low(MMU_REG_BASE) ; Set MMU_REG_BASE lower
ldi r1, #0
st r1, @(MPSZ_offset,r0) ; Set MPSZ Reg(Page size 4KB:0 16KB:1 64KB:2)
ldi r1, #0
st r1, @(MASID_offset,r0) ; Set ASID Zero
;; Set TLB
seth r0, #high(ITLB_BASE) ; Set ITLB_BASE higher
or3 r0, r0, #low(ITLB_BASE) ; Set ITLB_BASE lower
seth r1, #high(DTLB_BASE) ; Set DTLB_BASE higher
or3 r1, r1, #low(DTLB_BASE) ; Set DTLB_BASE lower
ldi r2, #0
ldi r3, #NR_TLB_ENTRIES
addi r0, #-4
addi r1, #-4
clear_tlb:
st r2, @+r0 ; VPA <- 0
st r2, @+r0 ; PPA <- 0
st r2, @+r1 ; VPA <- 0
st r2, @+r1 ; PPA <- 0
addi r3, #-1
bnez r3, clear_tlb
;;
jmp r14
ENTRY(m32r_itlb_entrys)
ENTRY(m32r_otlb_entrys)
#endif /* CONFIG_MMU */
.end