Skip to content

Commit 7f043b7

Browse files
committed
Merge tag 'loongarch-fixes-6.1-3' of git://git.kernel.org/pub/scm/linux/kernel/git/chenhuacai/linux-loongson
Pull LoongArch fixes from Huacai Chen: "Export smp_send_reschedule() for modules use, fix a huge page entry update issue, and add documents for booting description" * tag 'loongarch-fixes-6.1-3' of git://git.kernel.org/pub/scm/linux/kernel/git/chenhuacai/linux-loongson: docs/zh_CN: Add LoongArch booting description's translation docs/LoongArch: Add booting description LoongArch: mm: Fix huge page entry update for virtual machine LoongArch: Export symbol for function smp_send_reschedule()
2 parents a4c3a07 + 1385313 commit 7f043b7

File tree

7 files changed

+119
-24
lines changed

7 files changed

+119
-24
lines changed

Documentation/loongarch/booting.rst

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
.. SPDX-License-Identifier: GPL-2.0
2+
3+
=======================
4+
Booting Linux/LoongArch
5+
=======================
6+
7+
:Author: Yanteng Si <[email protected]>
8+
:Date: 18 Nov 2022
9+
10+
Information passed from BootLoader to kernel
11+
============================================
12+
13+
LoongArch supports ACPI and FDT. The information that needs to be passed
14+
to the kernel includes the memmap, the initrd, the command line, optionally
15+
the ACPI/FDT tables, and so on.
16+
17+
The kernel is passed the following arguments on `kernel_entry` :
18+
19+
- a0 = efi_boot: `efi_boot` is a flag indicating whether
20+
this boot environment is fully UEFI-compliant.
21+
22+
- a1 = cmdline: `cmdline` is a pointer to the kernel command line.
23+
24+
- a2 = systemtable: `systemtable` points to the EFI system table.
25+
All pointers involved at this stage are in physical addresses.
26+
27+
Header of Linux/LoongArch kernel images
28+
=======================================
29+
30+
Linux/LoongArch kernel images are EFI images. Being PE files, they have
31+
a 64-byte header structured like::
32+
33+
u32 MZ_MAGIC /* "MZ", MS-DOS header */
34+
u32 res0 = 0 /* Reserved */
35+
u64 kernel_entry /* Kernel entry point */
36+
u64 _end - _text /* Kernel image effective size */
37+
u64 load_offset /* Kernel image load offset from start of RAM */
38+
u64 res1 = 0 /* Reserved */
39+
u64 res2 = 0 /* Reserved */
40+
u64 res3 = 0 /* Reserved */
41+
u32 LINUX_PE_MAGIC /* Magic number */
42+
u32 pe_header - _head /* Offset to the PE header */

Documentation/loongarch/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ LoongArch Architecture
99
:numbered:
1010

1111
introduction
12+
booting
1213
irq-chip-model
1314

1415
features
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
.. SPDX-License-Identifier: GPL-2.0
2+
3+
.. include:: ../disclaimer-zh_CN.rst
4+
5+
:Original: Documentation/loongarch/booting.rst
6+
7+
:翻译:
8+
9+
司延腾 Yanteng Si <[email protected]>
10+
11+
====================
12+
启动 Linux/LoongArch
13+
====================
14+
15+
:作者: 司延腾 <[email protected]>
16+
:日期: 2022年11月18日
17+
18+
BootLoader传递给内核的信息
19+
==========================
20+
21+
LoongArch支持ACPI和FDT启动,需要传递给内核的信息包括memmap、initrd、cmdline、可
22+
选的ACPI/FDT表等。
23+
24+
内核在 `kernel_entry` 入口处被传递以下参数:
25+
26+
- a0 = efi_boot: `efi_boot` 是一个标志,表示这个启动环境是否完全符合UEFI
27+
的要求。
28+
29+
- a1 = cmdline: `cmdline` 是一个指向内核命令行的指针。
30+
31+
- a2 = systemtable: `systemtable` 指向EFI的系统表,在这个阶段涉及的所有
32+
指针都是物理地址。
33+
34+
Linux/LoongArch内核镜像文件头
35+
=============================
36+
37+
内核镜像是EFI镜像。作为PE文件,它们有一个64字节的头部结构体,如下所示::
38+
39+
u32 MZ_MAGIC /* "MZ", MS-DOS 头 */
40+
u32 res0 = 0 /* 保留 */
41+
u64 kernel_entry /* 内核入口点 */
42+
u64 _end - _text /* 内核镜像有效大小 */
43+
u64 load_offset /* 加载内核镜像相对内存起始地址的偏移量 */
44+
u64 res1 = 0 /* 保留 */
45+
u64 res2 = 0 /* 保留 */
46+
u64 res3 = 0 /* 保留 */
47+
u32 LINUX_PE_MAGIC /* 魔术数 */
48+
u32 pe_header - _head /* 到PE头的偏移量 */

Documentation/translations/zh_CN/loongarch/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ LoongArch体系结构
1414
:numbered:
1515

1616
introduction
17+
booting
1718
irq-chip-model
1819

1920
features

arch/loongarch/include/asm/smp.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -78,16 +78,6 @@ extern void calculate_cpu_foreign_map(void);
7878
*/
7979
extern void show_ipi_list(struct seq_file *p, int prec);
8080

81-
/*
82-
* This function sends a 'reschedule' IPI to another CPU.
83-
* it goes straight through and wastes no time serializing
84-
* anything. Worst case is that we lose a reschedule ...
85-
*/
86-
static inline void smp_send_reschedule(int cpu)
87-
{
88-
loongson_send_ipi_single(cpu, SMP_RESCHEDULE);
89-
}
90-
9181
static inline void arch_send_call_function_single_ipi(int cpu)
9282
{
9383
loongson_send_ipi_single(cpu, SMP_CALL_FUNCTION);

arch/loongarch/kernel/smp.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,17 @@ void loongson_send_ipi_mask(const struct cpumask *mask, unsigned int action)
149149
ipi_write_action(cpu_logical_map(i), (u32)action);
150150
}
151151

152+
/*
153+
* This function sends a 'reschedule' IPI to another CPU.
154+
* it goes straight through and wastes no time serializing
155+
* anything. Worst case is that we lose a reschedule ...
156+
*/
157+
void smp_send_reschedule(int cpu)
158+
{
159+
loongson_send_ipi_single(cpu, SMP_RESCHEDULE);
160+
}
161+
EXPORT_SYMBOL_GPL(smp_send_reschedule);
162+
152163
irqreturn_t loongson_ipi_interrupt(int irq, void *dev)
153164
{
154165
unsigned int action;

arch/loongarch/mm/tlbex.S

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
#include <asm/regdef.h>
1111
#include <asm/stackframe.h>
1212

13+
#define INVTLB_ADDR_GFALSE_AND_ASID 5
14+
1315
#define PTRS_PER_PGD_BITS (PAGE_SHIFT - 3)
1416
#define PTRS_PER_PUD_BITS (PAGE_SHIFT - 3)
1517
#define PTRS_PER_PMD_BITS (PAGE_SHIFT - 3)
@@ -136,13 +138,10 @@ tlb_huge_update_load:
136138
ori t0, ra, _PAGE_VALID
137139
st.d t0, t1, 0
138140
#endif
139-
tlbsrch
140-
addu16i.d t1, zero, -(CSR_TLBIDX_EHINV >> 16)
141-
addi.d ra, t1, 0
142-
csrxchg ra, t1, LOONGARCH_CSR_TLBIDX
143-
tlbwr
144-
145-
csrxchg zero, t1, LOONGARCH_CSR_TLBIDX
141+
csrrd ra, LOONGARCH_CSR_ASID
142+
csrrd t1, LOONGARCH_CSR_BADV
143+
andi ra, ra, CSR_ASID_ASID
144+
invtlb INVTLB_ADDR_GFALSE_AND_ASID, ra, t1
146145

147146
/*
148147
* A huge PTE describes an area the size of the
@@ -287,13 +286,11 @@ tlb_huge_update_store:
287286
ori t0, ra, (_PAGE_VALID | _PAGE_DIRTY | _PAGE_MODIFIED)
288287
st.d t0, t1, 0
289288
#endif
290-
tlbsrch
291-
addu16i.d t1, zero, -(CSR_TLBIDX_EHINV >> 16)
292-
addi.d ra, t1, 0
293-
csrxchg ra, t1, LOONGARCH_CSR_TLBIDX
294-
tlbwr
289+
csrrd ra, LOONGARCH_CSR_ASID
290+
csrrd t1, LOONGARCH_CSR_BADV
291+
andi ra, ra, CSR_ASID_ASID
292+
invtlb INVTLB_ADDR_GFALSE_AND_ASID, ra, t1
295293

296-
csrxchg zero, t1, LOONGARCH_CSR_TLBIDX
297294
/*
298295
* A huge PTE describes an area the size of the
299296
* configured huge page size. This is twice the
@@ -436,6 +433,11 @@ tlb_huge_update_modify:
436433
ori t0, ra, (_PAGE_VALID | _PAGE_DIRTY | _PAGE_MODIFIED)
437434
st.d t0, t1, 0
438435
#endif
436+
csrrd ra, LOONGARCH_CSR_ASID
437+
csrrd t1, LOONGARCH_CSR_BADV
438+
andi ra, ra, CSR_ASID_ASID
439+
invtlb INVTLB_ADDR_GFALSE_AND_ASID, ra, t1
440+
439441
/*
440442
* A huge PTE describes an area the size of the
441443
* configured huge page size. This is twice the
@@ -466,7 +468,7 @@ tlb_huge_update_modify:
466468
addu16i.d t1, zero, (PS_HUGE_SIZE << (CSR_TLBIDX_PS_SHIFT - 16))
467469
csrxchg t1, t0, LOONGARCH_CSR_TLBIDX
468470

469-
tlbwr
471+
tlbfill
470472

471473
/* Reset default page size */
472474
addu16i.d t0, zero, (CSR_TLBIDX_PS >> 16)

0 commit comments

Comments
 (0)