Skip to content

Commit ab68d7e

Browse files
committed
Merge tag 'loongarch-fixes-6.14-1' of git://git.kernel.org/pub/scm/linux/kernel/git/chenhuacai/linux-loongson
Pull LoongArch fixes from Huacai Chen: "Fix bugs about idle, kernel_page_present(), IP checksum and KVM, plus some trival cleanups" * tag 'loongarch-fixes-6.14-1' of git://git.kernel.org/pub/scm/linux/kernel/git/chenhuacai/linux-loongson: LoongArch: KVM: Set host with kernel mode when switch to VM mode LoongArch: KVM: Remove duplicated cache attribute setting LoongArch: KVM: Fix typo issue about GCFG feature detection LoongArch: csum: Fix OoB access in IP checksum code for negative lengths LoongArch: Remove the deprecated notifier hook mechanism LoongArch: Use str_yes_no() helper function for /proc/cpuinfo LoongArch: Fix kernel_page_present() for KPRANGE/XKPRANGE LoongArch: Fix idle VS timer enqueue
2 parents d63609e + 3011b29 commit ab68d7e

File tree

11 files changed

+30
-73
lines changed

11 files changed

+30
-73
lines changed

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

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -76,27 +76,6 @@ extern const char *__cpu_full_name[];
7676
#define cpu_family_string() __cpu_family[raw_smp_processor_id()]
7777
#define cpu_full_name_string() __cpu_full_name[raw_smp_processor_id()]
7878

79-
struct seq_file;
80-
struct notifier_block;
81-
82-
extern int register_proc_cpuinfo_notifier(struct notifier_block *nb);
83-
extern int proc_cpuinfo_notifier_call_chain(unsigned long val, void *v);
84-
85-
#define proc_cpuinfo_notifier(fn, pri) \
86-
({ \
87-
static struct notifier_block fn##_nb = { \
88-
.notifier_call = fn, \
89-
.priority = pri \
90-
}; \
91-
\
92-
register_proc_cpuinfo_notifier(&fn##_nb); \
93-
})
94-
95-
struct proc_cpuinfo_notifier_args {
96-
struct seq_file *m;
97-
unsigned long n;
98-
};
99-
10079
static inline bool cpus_are_siblings(int cpua, int cpub)
10180
{
10281
struct cpuinfo_loongarch *infoa = &cpu_data[cpua];

arch/loongarch/include/asm/smp.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ extern int __cpu_logical_map[NR_CPUS];
7777
#define SMP_IRQ_WORK BIT(ACTION_IRQ_WORK)
7878
#define SMP_CLEAR_VECTOR BIT(ACTION_CLEAR_VECTOR)
7979

80+
struct seq_file;
81+
8082
struct secondary_data {
8183
unsigned long stack;
8284
unsigned long thread_info;

arch/loongarch/kernel/genex.S

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,28 +18,30 @@
1818

1919
.align 5
2020
SYM_FUNC_START(__arch_cpu_idle)
21-
/* start of rollback region */
22-
LONG_L t0, tp, TI_FLAGS
23-
nop
24-
andi t0, t0, _TIF_NEED_RESCHED
25-
bnez t0, 1f
26-
nop
27-
nop
28-
nop
21+
/* start of idle interrupt region */
22+
ori t0, zero, CSR_CRMD_IE
23+
/* idle instruction needs irq enabled */
24+
csrxchg t0, t0, LOONGARCH_CSR_CRMD
25+
/*
26+
* If an interrupt lands here; between enabling interrupts above and
27+
* going idle on the next instruction, we must *NOT* go idle since the
28+
* interrupt could have set TIF_NEED_RESCHED or caused an timer to need
29+
* reprogramming. Fall through -- see handle_vint() below -- and have
30+
* the idle loop take care of things.
31+
*/
2932
idle 0
30-
/* end of rollback region */
33+
/* end of idle interrupt region */
3134
1: jr ra
3235
SYM_FUNC_END(__arch_cpu_idle)
3336

3437
SYM_CODE_START(handle_vint)
3538
UNWIND_HINT_UNDEFINED
3639
BACKUP_T0T1
3740
SAVE_ALL
38-
la_abs t1, __arch_cpu_idle
41+
la_abs t1, 1b
3942
LONG_L t0, sp, PT_ERA
40-
/* 32 byte rollback region */
41-
ori t0, t0, 0x1f
42-
xori t0, t0, 0x1f
43+
/* 3 instructions idle interrupt region */
44+
ori t0, t0, 0b1100
4345
bne t0, t1, 1f
4446
LONG_S t0, sp, PT_ERA
4547
1: move a0, sp

arch/loongarch/kernel/idle.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
void __cpuidle arch_cpu_idle(void)
1313
{
14-
raw_local_irq_enable();
15-
__arch_cpu_idle(); /* idle instruction needs irq enabled */
14+
__arch_cpu_idle();
1615
raw_local_irq_disable();
1716
}

arch/loongarch/kernel/proc.c

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -13,28 +13,12 @@
1313
#include <asm/processor.h>
1414
#include <asm/time.h>
1515

16-
/*
17-
* No lock; only written during early bootup by CPU 0.
18-
*/
19-
static RAW_NOTIFIER_HEAD(proc_cpuinfo_chain);
20-
21-
int __ref register_proc_cpuinfo_notifier(struct notifier_block *nb)
22-
{
23-
return raw_notifier_chain_register(&proc_cpuinfo_chain, nb);
24-
}
25-
26-
int proc_cpuinfo_notifier_call_chain(unsigned long val, void *v)
27-
{
28-
return raw_notifier_call_chain(&proc_cpuinfo_chain, val, v);
29-
}
30-
3116
static int show_cpuinfo(struct seq_file *m, void *v)
3217
{
3318
unsigned long n = (unsigned long) v - 1;
3419
unsigned int isa = cpu_data[n].isa_level;
3520
unsigned int version = cpu_data[n].processor_id & 0xff;
3621
unsigned int fp_version = cpu_data[n].fpu_vers;
37-
struct proc_cpuinfo_notifier_args proc_cpuinfo_notifier_args;
3822

3923
#ifdef CONFIG_SMP
4024
if (!cpu_online(n))
@@ -91,20 +75,13 @@ static int show_cpuinfo(struct seq_file *m, void *v)
9175
if (cpu_has_lbt_mips) seq_printf(m, " lbt_mips");
9276
seq_printf(m, "\n");
9377

94-
seq_printf(m, "Hardware Watchpoint\t: %s",
95-
cpu_has_watch ? "yes, " : "no\n");
78+
seq_printf(m, "Hardware Watchpoint\t: %s", str_yes_no(cpu_has_watch));
9679
if (cpu_has_watch) {
97-
seq_printf(m, "iwatch count: %d, dwatch count: %d\n",
80+
seq_printf(m, ", iwatch count: %d, dwatch count: %d",
9881
cpu_data[n].watch_ireg_count, cpu_data[n].watch_dreg_count);
9982
}
10083

101-
proc_cpuinfo_notifier_args.m = m;
102-
proc_cpuinfo_notifier_args.n = n;
103-
104-
raw_notifier_call_chain(&proc_cpuinfo_chain, 0,
105-
&proc_cpuinfo_notifier_args);
106-
107-
seq_printf(m, "\n");
84+
seq_printf(m, "\n\n");
10885

10986
return 0;
11087
}

arch/loongarch/kernel/reset.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ void machine_halt(void)
3333
console_flush_on_panic(CONSOLE_FLUSH_PENDING);
3434

3535
while (true) {
36-
__arch_cpu_idle();
36+
__asm__ __volatile__("idle 0" : : : "memory");
3737
}
3838
}
3939

@@ -53,7 +53,7 @@ void machine_power_off(void)
5353
#endif
5454

5555
while (true) {
56-
__arch_cpu_idle();
56+
__asm__ __volatile__("idle 0" : : : "memory");
5757
}
5858
}
5959

@@ -74,6 +74,6 @@ void machine_restart(char *command)
7474
acpi_reboot();
7575

7676
while (true) {
77-
__arch_cpu_idle();
77+
__asm__ __volatile__("idle 0" : : : "memory");
7878
}
7979
}

arch/loongarch/kvm/main.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,9 +303,9 @@ int kvm_arch_enable_virtualization_cpu(void)
303303
* TOE=0: Trap on Exception.
304304
* TIT=0: Trap on Timer.
305305
*/
306-
if (env & CSR_GCFG_GCIP_ALL)
306+
if (env & CSR_GCFG_GCIP_SECURE)
307307
gcfg |= CSR_GCFG_GCI_SECURE;
308-
if (env & CSR_GCFG_MATC_ROOT)
308+
if (env & CSR_GCFG_MATP_ROOT)
309309
gcfg |= CSR_GCFG_MATC_ROOT;
310310

311311
write_csr_gcfg(gcfg);

arch/loongarch/kvm/switch.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
* Guest CRMD comes from separate GCSR_CRMD register
8686
*/
8787
ori t0, zero, CSR_PRMD_PIE
88-
csrxchg t0, t0, LOONGARCH_CSR_PRMD
88+
csrwr t0, LOONGARCH_CSR_PRMD
8989

9090
/* Set PVM bit to setup ertn to guest context */
9191
ori t0, zero, CSR_GSTAT_PVM

arch/loongarch/kvm/vcpu.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1548,9 +1548,6 @@ static int _kvm_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
15481548

15491549
/* Restore timer state regardless */
15501550
kvm_restore_timer(vcpu);
1551-
1552-
/* Control guest page CCA attribute */
1553-
change_csr_gcfg(CSR_GCFG_MATC_MASK, CSR_GCFG_MATC_ROOT);
15541551
kvm_make_request(KVM_REQ_STEAL_UPDATE, vcpu);
15551552

15561553
/* Restore hardware PMU CSRs */

arch/loongarch/lib/csum.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ unsigned int __no_sanitize_address do_csum(const unsigned char *buff, int len)
2525
const u64 *ptr;
2626
u64 data, sum64 = 0;
2727

28-
if (unlikely(len == 0))
28+
if (unlikely(len <= 0))
2929
return 0;
3030

3131
offset = (unsigned long)buff & 7;

0 commit comments

Comments
 (0)