Skip to content

Commit e927c52

Browse files
committed
Merge tag 'loongarch-fixes-6.18-1' of git://git.kernel.org/pub/scm/linux/kernel/git/chenhuacai/linux-loongson
Pull LoongArch fixes from Huacai Chen: - Fix a Rust build error - Fix exception/interrupt, memory management, perf event, hardware breakpoint, kexec and KVM bugs * tag 'loongarch-fixes-6.18-1' of git://git.kernel.org/pub/scm/linux/kernel/git/chenhuacai/linux-loongson: LoongArch: KVM: Fix max supported vCPUs set with EIOINTC LoongArch: KVM: Skip PMU checking on vCPU context switch LoongArch: KVM: Restore guest PMU if it is enabled LoongArch: KVM: Add delay until timer interrupt injected LoongArch: KVM: Set page with write attribute if dirty track disabled LoongArch: kexec: Print out debugging message if required LoongArch: kexec: Initialize the kexec_buf structure LoongArch: Use correct accessor to read FWPC/MWPC LoongArch: Refine the init_hw_perf_events() function LoongArch: Remove __GFP_HIGHMEM masking in pud_alloc_one() LoongArch: Let {pte,pmd}_modify() record the status of _PAGE_DIRTY LoongArch: Consolidate max_pfn & max_low_pfn calculation LoongArch: Consolidate early_ioremap()/ioremap_prot() LoongArch: Use physical addresses for CSR_MERRENTRY/CSR_TLBRENTRY LoongArch: Clarify 3 MSG interrupt features rust: Add -fno-isolate-erroneous-paths-dereference to bindgen_skip_c_flags
2 parents 89ee862 + 237e74b commit e927c52

24 files changed

Lines changed: 59 additions & 82 deletions

arch/loongarch/include/asm/cpu-features.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@
6767
#define cpu_has_hypervisor cpu_opt(LOONGARCH_CPU_HYPERVISOR)
6868
#define cpu_has_ptw cpu_opt(LOONGARCH_CPU_PTW)
6969
#define cpu_has_lspw cpu_opt(LOONGARCH_CPU_LSPW)
70+
#define cpu_has_msgint cpu_opt(LOONGARCH_CPU_MSGINT)
7071
#define cpu_has_avecint cpu_opt(LOONGARCH_CPU_AVECINT)
72+
#define cpu_has_redirectint cpu_opt(LOONGARCH_CPU_REDIRECTINT)
7173

7274
#endif /* __ASM_CPU_FEATURES_H */

arch/loongarch/include/asm/cpu.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,9 @@ enum cpu_type_enum {
101101
#define CPU_FEATURE_HYPERVISOR 26 /* CPU has hypervisor (running in VM) */
102102
#define CPU_FEATURE_PTW 27 /* CPU has hardware page table walker */
103103
#define CPU_FEATURE_LSPW 28 /* CPU has LSPW (lddir/ldpte instructions) */
104-
#define CPU_FEATURE_AVECINT 29 /* CPU has AVEC interrupt */
104+
#define CPU_FEATURE_MSGINT 29 /* CPU has MSG interrupt */
105+
#define CPU_FEATURE_AVECINT 30 /* CPU has AVEC interrupt */
106+
#define CPU_FEATURE_REDIRECTINT 31 /* CPU has interrupt remapping */
105107

106108
#define LOONGARCH_CPU_CPUCFG BIT_ULL(CPU_FEATURE_CPUCFG)
107109
#define LOONGARCH_CPU_LAM BIT_ULL(CPU_FEATURE_LAM)
@@ -132,6 +134,8 @@ enum cpu_type_enum {
132134
#define LOONGARCH_CPU_HYPERVISOR BIT_ULL(CPU_FEATURE_HYPERVISOR)
133135
#define LOONGARCH_CPU_PTW BIT_ULL(CPU_FEATURE_PTW)
134136
#define LOONGARCH_CPU_LSPW BIT_ULL(CPU_FEATURE_LSPW)
137+
#define LOONGARCH_CPU_MSGINT BIT_ULL(CPU_FEATURE_MSGINT)
135138
#define LOONGARCH_CPU_AVECINT BIT_ULL(CPU_FEATURE_AVECINT)
139+
#define LOONGARCH_CPU_REDIRECTINT BIT_ULL(CPU_FEATURE_REDIRECTINT)
136140

137141
#endif /* _ASM_CPU_H */

arch/loongarch/include/asm/hw_breakpoint.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,13 +134,13 @@ static inline void hw_breakpoint_thread_switch(struct task_struct *next)
134134
/* Determine number of BRP registers available. */
135135
static inline int get_num_brps(void)
136136
{
137-
return csr_read64(LOONGARCH_CSR_FWPC) & CSR_FWPC_NUM;
137+
return csr_read32(LOONGARCH_CSR_FWPC) & CSR_FWPC_NUM;
138138
}
139139

140140
/* Determine number of WRP registers available. */
141141
static inline int get_num_wrps(void)
142142
{
143-
return csr_read64(LOONGARCH_CSR_MWPC) & CSR_MWPC_NUM;
143+
return csr_read32(LOONGARCH_CSR_MWPC) & CSR_MWPC_NUM;
144144
}
145145

146146
#endif /* __KERNEL__ */

arch/loongarch/include/asm/io.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#include <asm/pgtable-bits.h>
1515
#include <asm/string.h>
1616

17-
extern void __init __iomem *early_ioremap(u64 phys_addr, unsigned long size);
17+
extern void __init __iomem *early_ioremap(phys_addr_t phys_addr, unsigned long size);
1818
extern void __init early_iounmap(void __iomem *addr, unsigned long size);
1919

2020
#define early_memremap early_ioremap
@@ -25,6 +25,9 @@ extern void __init early_iounmap(void __iomem *addr, unsigned long size);
2525
static inline void __iomem *ioremap_prot(phys_addr_t offset, unsigned long size,
2626
pgprot_t prot)
2727
{
28+
if (offset > TO_PHYS_MASK)
29+
return NULL;
30+
2831
switch (pgprot_val(prot) & _CACHE_MASK) {
2932
case _CACHE_CC:
3033
return (void __iomem *)(unsigned long)(CACHE_BASE + offset);

arch/loongarch/include/asm/loongarch.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@
128128
#define CPUCFG6_PMNUM GENMASK(7, 4)
129129
#define CPUCFG6_PMNUM_SHIFT 4
130130
#define CPUCFG6_PMBITS GENMASK(13, 8)
131+
#define CPUCFG6_PMBITS_SHIFT 8
131132
#define CPUCFG6_UPM BIT(14)
132133

133134
#define LOONGARCH_CPUCFG16 0x10
@@ -1137,6 +1138,7 @@
11371138
#define IOCSRF_FLATMODE BIT_ULL(10)
11381139
#define IOCSRF_VM BIT_ULL(11)
11391140
#define IOCSRF_AVEC BIT_ULL(15)
1141+
#define IOCSRF_REDIRECT BIT_ULL(16)
11401142

11411143
#define LOONGARCH_IOCSR_VENDOR 0x10
11421144

arch/loongarch/include/asm/pgalloc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address)
8888
static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long address)
8989
{
9090
pud_t *pud;
91-
struct ptdesc *ptdesc = pagetable_alloc(GFP_KERNEL & ~__GFP_HIGHMEM, 0);
91+
struct ptdesc *ptdesc = pagetable_alloc(GFP_KERNEL, 0);
9292

9393
if (!ptdesc)
9494
return NULL;

arch/loongarch/include/asm/pgtable.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,9 @@ static inline unsigned long pte_accessible(struct mm_struct *mm, pte_t a)
424424

425425
static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
426426
{
427+
if (pte_val(pte) & _PAGE_DIRTY)
428+
pte_val(pte) |= _PAGE_MODIFIED;
429+
427430
return __pte((pte_val(pte) & _PAGE_CHG_MASK) |
428431
(pgprot_val(newprot) & ~_PAGE_CHG_MASK));
429432
}
@@ -547,9 +550,11 @@ static inline struct page *pmd_page(pmd_t pmd)
547550

548551
static inline pmd_t pmd_modify(pmd_t pmd, pgprot_t newprot)
549552
{
550-
pmd_val(pmd) = (pmd_val(pmd) & _HPAGE_CHG_MASK) |
551-
(pgprot_val(newprot) & ~_HPAGE_CHG_MASK);
552-
return pmd;
553+
if (pmd_val(pmd) & _PAGE_DIRTY)
554+
pmd_val(pmd) |= _PAGE_MODIFIED;
555+
556+
return __pmd((pmd_val(pmd) & _HPAGE_CHG_MASK) |
557+
(pgprot_val(newprot) & ~_HPAGE_CHG_MASK));
553558
}
554559

555560
static inline pmd_t pmd_mkinvalid(pmd_t pmd)

arch/loongarch/kernel/cpu-probe.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,8 @@ static void cpu_probe_common(struct cpuinfo_loongarch *c)
157157
c->options |= LOONGARCH_CPU_TLB;
158158
if (config & CPUCFG1_IOCSR)
159159
c->options |= LOONGARCH_CPU_IOCSR;
160+
if (config & CPUCFG1_MSGINT)
161+
c->options |= LOONGARCH_CPU_MSGINT;
160162
if (config & CPUCFG1_UAL) {
161163
c->options |= LOONGARCH_CPU_UAL;
162164
elf_hwcap |= HWCAP_LOONGARCH_UAL;
@@ -331,6 +333,8 @@ static inline void cpu_probe_loongson(struct cpuinfo_loongarch *c, unsigned int
331333
c->options |= LOONGARCH_CPU_EIODECODE;
332334
if (config & IOCSRF_AVEC)
333335
c->options |= LOONGARCH_CPU_AVECINT;
336+
if (config & IOCSRF_REDIRECT)
337+
c->options |= LOONGARCH_CPU_REDIRECTINT;
334338
if (config & IOCSRF_VM)
335339
c->options |= LOONGARCH_CPU_HYPERVISOR;
336340
}

arch/loongarch/kernel/kexec_efi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ static void *efi_kexec_load(struct kimage *image,
4242
{
4343
int ret;
4444
unsigned long text_offset, kernel_segment_number;
45-
struct kexec_buf kbuf;
45+
struct kexec_buf kbuf = {};
4646
struct kexec_segment *kernel_segment;
4747
struct loongarch_image_header *h;
4848

arch/loongarch/kernel/kexec_elf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ static void *elf_kexec_load(struct kimage *image,
5959
int ret;
6060
unsigned long text_offset, kernel_segment_number;
6161
struct elfhdr ehdr;
62-
struct kexec_buf kbuf;
62+
struct kexec_buf kbuf = {};
6363
struct kexec_elf_info elf_info;
6464
struct kexec_segment *kernel_segment;
6565

0 commit comments

Comments
 (0)