Skip to content

Commit 74099e2

Browse files
committed
Merge tag 'mips_6.5_1' of git://git.kernel.org/pub/scm/linux/kernel/git/mips/linux
Pull MIPS fixes from Thomas Bogendoerfer: - fixes for KVM - fix for loongson build and cpu probing - DT fixes * tag 'mips_6.5_1' of git://git.kernel.org/pub/scm/linux/kernel/git/mips/linux: MIPS: kvm: Fix build error with KVM_MIPS_DEBUG_COP0_COUNTERS enabled MIPS: dts: add missing space before { MIPS: Loongson: Fix build error when make modules_install MIPS: KVM: Fix NULL pointer dereference MIPS: Loongson: Fix cpu_probe_loongson() again
2 parents 7648784 + 3a6dbb6 commit 74099e2

File tree

10 files changed

+46
-53
lines changed

10 files changed

+46
-53
lines changed

arch/mips/Makefile

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -181,16 +181,12 @@ endif
181181
cflags-$(CONFIG_CAVIUM_CN63XXP1) += -Wa,-mfix-cn63xxp1
182182
cflags-$(CONFIG_CPU_BMIPS) += -march=mips32 -Wa,-mips32 -Wa,--trap
183183

184-
cflags-$(CONFIG_CPU_LOONGSON2E) += -march=loongson2e -Wa,--trap
185-
cflags-$(CONFIG_CPU_LOONGSON2F) += -march=loongson2f -Wa,--trap
184+
cflags-$(CONFIG_CPU_LOONGSON2E) += $(call cc-option,-march=loongson2e) -Wa,--trap
185+
cflags-$(CONFIG_CPU_LOONGSON2F) += $(call cc-option,-march=loongson2f) -Wa,--trap
186+
cflags-$(CONFIG_CPU_LOONGSON64) += $(call cc-option,-march=loongson3a,-march=mips64r2) -Wa,--trap
186187
# Some -march= flags enable MMI instructions, and GCC complains about that
187188
# support being enabled alongside -msoft-float. Thus explicitly disable MMI.
188189
cflags-$(CONFIG_CPU_LOONGSON2EF) += $(call cc-option,-mno-loongson-mmi)
189-
ifdef CONFIG_CPU_LOONGSON64
190-
cflags-$(CONFIG_CPU_LOONGSON64) += -Wa,--trap
191-
cflags-$(CONFIG_CC_IS_GCC) += -march=loongson3a
192-
cflags-$(CONFIG_CC_IS_CLANG) += -march=mips64r2
193-
endif
194190
cflags-$(CONFIG_CPU_LOONGSON64) += $(call cc-option,-mno-loongson-mmi)
195191

196192
cflags-$(CONFIG_CPU_R4000_WORKAROUNDS) += $(call cc-option,-mfix-r4000,)

arch/mips/boot/dts/mscc/serval_common.dtsi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
stdout-path = "serial0:115200n8";
2121
};
2222

23-
i2c0_imux: i2c0-imux{
23+
i2c0_imux: i2c0-imux {
2424
compatible = "i2c-mux-pinctrl";
2525
#address-cells = <1>;
2626
#size-cells = <0>;

arch/mips/boot/dts/pic32/pic32mzda.dtsi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
microchip,external-irqs = <3 8 13 18 23>;
7676
};
7777

78-
pic32_pinctrl: pinctrl@1f801400{
78+
pic32_pinctrl: pinctrl@1f801400 {
7979
#address-cells = <1>;
8080
#size-cells = <1>;
8181
compatible = "microchip,pic32mzda-pinctrl";

arch/mips/include/asm/kvm_host.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ struct kvm_vcpu_arch {
317317
unsigned int aux_inuse;
318318

319319
/* COP0 State */
320-
struct mips_coproc *cop0;
320+
struct mips_coproc cop0;
321321

322322
/* Resume PC after MMIO completion */
323323
unsigned long io_pc;
@@ -698,7 +698,7 @@ static inline bool kvm_mips_guest_can_have_fpu(struct kvm_vcpu_arch *vcpu)
698698
static inline bool kvm_mips_guest_has_fpu(struct kvm_vcpu_arch *vcpu)
699699
{
700700
return kvm_mips_guest_can_have_fpu(vcpu) &&
701-
kvm_read_c0_guest_config1(vcpu->cop0) & MIPS_CONF1_FP;
701+
kvm_read_c0_guest_config1(&vcpu->cop0) & MIPS_CONF1_FP;
702702
}
703703

704704
static inline bool kvm_mips_guest_can_have_msa(struct kvm_vcpu_arch *vcpu)
@@ -710,7 +710,7 @@ static inline bool kvm_mips_guest_can_have_msa(struct kvm_vcpu_arch *vcpu)
710710
static inline bool kvm_mips_guest_has_msa(struct kvm_vcpu_arch *vcpu)
711711
{
712712
return kvm_mips_guest_can_have_msa(vcpu) &&
713-
kvm_read_c0_guest_config3(vcpu->cop0) & MIPS_CONF3_MSA;
713+
kvm_read_c0_guest_config3(&vcpu->cop0) & MIPS_CONF3_MSA;
714714
}
715715

716716
struct kvm_mips_callbacks {

arch/mips/kernel/cpu-probe.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1677,7 +1677,10 @@ static inline void decode_cpucfg(struct cpuinfo_mips *c)
16771677

16781678
static inline void cpu_probe_loongson(struct cpuinfo_mips *c, unsigned int cpu)
16791679
{
1680+
c->cputype = CPU_LOONGSON64;
1681+
16801682
/* All Loongson processors covered here define ExcCode 16 as GSExc. */
1683+
decode_configs(c);
16811684
c->options |= MIPS_CPU_GSEXCEX;
16821685

16831686
switch (c->processor_id & PRID_IMP_MASK) {
@@ -1687,7 +1690,6 @@ static inline void cpu_probe_loongson(struct cpuinfo_mips *c, unsigned int cpu)
16871690
case PRID_REV_LOONGSON2K_R1_1:
16881691
case PRID_REV_LOONGSON2K_R1_2:
16891692
case PRID_REV_LOONGSON2K_R1_3:
1690-
c->cputype = CPU_LOONGSON64;
16911693
__cpu_name[cpu] = "Loongson-2K";
16921694
set_elf_platform(cpu, "gs264e");
16931695
set_isa(c, MIPS_CPU_ISA_M64R2);
@@ -1700,14 +1702,12 @@ static inline void cpu_probe_loongson(struct cpuinfo_mips *c, unsigned int cpu)
17001702
switch (c->processor_id & PRID_REV_MASK) {
17011703
case PRID_REV_LOONGSON3A_R2_0:
17021704
case PRID_REV_LOONGSON3A_R2_1:
1703-
c->cputype = CPU_LOONGSON64;
17041705
__cpu_name[cpu] = "ICT Loongson-3";
17051706
set_elf_platform(cpu, "loongson3a");
17061707
set_isa(c, MIPS_CPU_ISA_M64R2);
17071708
break;
17081709
case PRID_REV_LOONGSON3A_R3_0:
17091710
case PRID_REV_LOONGSON3A_R3_1:
1710-
c->cputype = CPU_LOONGSON64;
17111711
__cpu_name[cpu] = "ICT Loongson-3";
17121712
set_elf_platform(cpu, "loongson3a");
17131713
set_isa(c, MIPS_CPU_ISA_M64R2);
@@ -1727,7 +1727,6 @@ static inline void cpu_probe_loongson(struct cpuinfo_mips *c, unsigned int cpu)
17271727
c->ases &= ~MIPS_ASE_VZ; /* VZ of Loongson-3A2000/3000 is incomplete */
17281728
break;
17291729
case PRID_IMP_LOONGSON_64G:
1730-
c->cputype = CPU_LOONGSON64;
17311730
__cpu_name[cpu] = "ICT Loongson-3";
17321731
set_elf_platform(cpu, "loongson3a");
17331732
set_isa(c, MIPS_CPU_ISA_M64R2);
@@ -1737,8 +1736,6 @@ static inline void cpu_probe_loongson(struct cpuinfo_mips *c, unsigned int cpu)
17371736
panic("Unknown Loongson Processor ID!");
17381737
break;
17391738
}
1740-
1741-
decode_configs(c);
17421739
}
17431740
#else
17441741
static inline void cpu_probe_loongson(struct cpuinfo_mips *c, unsigned int cpu) { }

arch/mips/kvm/emulate.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ int kvm_get_badinstrp(u32 *opc, struct kvm_vcpu *vcpu, u32 *out)
312312
*/
313313
int kvm_mips_count_disabled(struct kvm_vcpu *vcpu)
314314
{
315-
struct mips_coproc *cop0 = vcpu->arch.cop0;
315+
struct mips_coproc *cop0 = &vcpu->arch.cop0;
316316

317317
return (vcpu->arch.count_ctl & KVM_REG_MIPS_COUNT_CTL_DC) ||
318318
(kvm_read_c0_guest_cause(cop0) & CAUSEF_DC);
@@ -384,7 +384,7 @@ static inline ktime_t kvm_mips_count_time(struct kvm_vcpu *vcpu)
384384
*/
385385
static u32 kvm_mips_read_count_running(struct kvm_vcpu *vcpu, ktime_t now)
386386
{
387-
struct mips_coproc *cop0 = vcpu->arch.cop0;
387+
struct mips_coproc *cop0 = &vcpu->arch.cop0;
388388
ktime_t expires, threshold;
389389
u32 count, compare;
390390
int running;
@@ -444,7 +444,7 @@ static u32 kvm_mips_read_count_running(struct kvm_vcpu *vcpu, ktime_t now)
444444
*/
445445
u32 kvm_mips_read_count(struct kvm_vcpu *vcpu)
446446
{
447-
struct mips_coproc *cop0 = vcpu->arch.cop0;
447+
struct mips_coproc *cop0 = &vcpu->arch.cop0;
448448

449449
/* If count disabled just read static copy of count */
450450
if (kvm_mips_count_disabled(vcpu))
@@ -502,7 +502,7 @@ ktime_t kvm_mips_freeze_hrtimer(struct kvm_vcpu *vcpu, u32 *count)
502502
static void kvm_mips_resume_hrtimer(struct kvm_vcpu *vcpu,
503503
ktime_t now, u32 count)
504504
{
505-
struct mips_coproc *cop0 = vcpu->arch.cop0;
505+
struct mips_coproc *cop0 = &vcpu->arch.cop0;
506506
u32 compare;
507507
u64 delta;
508508
ktime_t expire;
@@ -603,7 +603,7 @@ int kvm_mips_restore_hrtimer(struct kvm_vcpu *vcpu, ktime_t before,
603603
*/
604604
void kvm_mips_write_count(struct kvm_vcpu *vcpu, u32 count)
605605
{
606-
struct mips_coproc *cop0 = vcpu->arch.cop0;
606+
struct mips_coproc *cop0 = &vcpu->arch.cop0;
607607
ktime_t now;
608608

609609
/* Calculate bias */
@@ -649,7 +649,7 @@ void kvm_mips_init_count(struct kvm_vcpu *vcpu, unsigned long count_hz)
649649
*/
650650
int kvm_mips_set_count_hz(struct kvm_vcpu *vcpu, s64 count_hz)
651651
{
652-
struct mips_coproc *cop0 = vcpu->arch.cop0;
652+
struct mips_coproc *cop0 = &vcpu->arch.cop0;
653653
int dc;
654654
ktime_t now;
655655
u32 count;
@@ -696,7 +696,7 @@ int kvm_mips_set_count_hz(struct kvm_vcpu *vcpu, s64 count_hz)
696696
*/
697697
void kvm_mips_write_compare(struct kvm_vcpu *vcpu, u32 compare, bool ack)
698698
{
699-
struct mips_coproc *cop0 = vcpu->arch.cop0;
699+
struct mips_coproc *cop0 = &vcpu->arch.cop0;
700700
int dc;
701701
u32 old_compare = kvm_read_c0_guest_compare(cop0);
702702
s32 delta = compare - old_compare;
@@ -779,7 +779,7 @@ void kvm_mips_write_compare(struct kvm_vcpu *vcpu, u32 compare, bool ack)
779779
*/
780780
static ktime_t kvm_mips_count_disable(struct kvm_vcpu *vcpu)
781781
{
782-
struct mips_coproc *cop0 = vcpu->arch.cop0;
782+
struct mips_coproc *cop0 = &vcpu->arch.cop0;
783783
u32 count;
784784
ktime_t now;
785785

@@ -806,7 +806,7 @@ static ktime_t kvm_mips_count_disable(struct kvm_vcpu *vcpu)
806806
*/
807807
void kvm_mips_count_disable_cause(struct kvm_vcpu *vcpu)
808808
{
809-
struct mips_coproc *cop0 = vcpu->arch.cop0;
809+
struct mips_coproc *cop0 = &vcpu->arch.cop0;
810810

811811
kvm_set_c0_guest_cause(cop0, CAUSEF_DC);
812812
if (!(vcpu->arch.count_ctl & KVM_REG_MIPS_COUNT_CTL_DC))
@@ -826,7 +826,7 @@ void kvm_mips_count_disable_cause(struct kvm_vcpu *vcpu)
826826
*/
827827
void kvm_mips_count_enable_cause(struct kvm_vcpu *vcpu)
828828
{
829-
struct mips_coproc *cop0 = vcpu->arch.cop0;
829+
struct mips_coproc *cop0 = &vcpu->arch.cop0;
830830
u32 count;
831831

832832
kvm_clear_c0_guest_cause(cop0, CAUSEF_DC);
@@ -852,7 +852,7 @@ void kvm_mips_count_enable_cause(struct kvm_vcpu *vcpu)
852852
*/
853853
int kvm_mips_set_count_ctl(struct kvm_vcpu *vcpu, s64 count_ctl)
854854
{
855-
struct mips_coproc *cop0 = vcpu->arch.cop0;
855+
struct mips_coproc *cop0 = &vcpu->arch.cop0;
856856
s64 changed = count_ctl ^ vcpu->arch.count_ctl;
857857
s64 delta;
858858
ktime_t expire, now;

arch/mips/kvm/mips.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -649,7 +649,7 @@ static int kvm_mips_copy_reg_indices(struct kvm_vcpu *vcpu, u64 __user *indices)
649649
static int kvm_mips_get_reg(struct kvm_vcpu *vcpu,
650650
const struct kvm_one_reg *reg)
651651
{
652-
struct mips_coproc *cop0 = vcpu->arch.cop0;
652+
struct mips_coproc *cop0 = &vcpu->arch.cop0;
653653
struct mips_fpu_struct *fpu = &vcpu->arch.fpu;
654654
int ret;
655655
s64 v;
@@ -761,7 +761,7 @@ static int kvm_mips_get_reg(struct kvm_vcpu *vcpu,
761761
static int kvm_mips_set_reg(struct kvm_vcpu *vcpu,
762762
const struct kvm_one_reg *reg)
763763
{
764-
struct mips_coproc *cop0 = vcpu->arch.cop0;
764+
struct mips_coproc *cop0 = &vcpu->arch.cop0;
765765
struct mips_fpu_struct *fpu = &vcpu->arch.fpu;
766766
s64 v;
767767
s64 vs[2];
@@ -1086,7 +1086,7 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext)
10861086
int kvm_cpu_has_pending_timer(struct kvm_vcpu *vcpu)
10871087
{
10881088
return kvm_mips_pending_timer(vcpu) ||
1089-
kvm_read_c0_guest_cause(vcpu->arch.cop0) & C_TI;
1089+
kvm_read_c0_guest_cause(&vcpu->arch.cop0) & C_TI;
10901090
}
10911091

10921092
int kvm_arch_vcpu_dump_regs(struct kvm_vcpu *vcpu)
@@ -1110,7 +1110,7 @@ int kvm_arch_vcpu_dump_regs(struct kvm_vcpu *vcpu)
11101110
kvm_debug("\thi: 0x%08lx\n", vcpu->arch.hi);
11111111
kvm_debug("\tlo: 0x%08lx\n", vcpu->arch.lo);
11121112

1113-
cop0 = vcpu->arch.cop0;
1113+
cop0 = &vcpu->arch.cop0;
11141114
kvm_debug("\tStatus: 0x%08x, Cause: 0x%08x\n",
11151115
kvm_read_c0_guest_status(cop0),
11161116
kvm_read_c0_guest_cause(cop0));
@@ -1232,7 +1232,7 @@ static int __kvm_mips_handle_exit(struct kvm_vcpu *vcpu)
12321232

12331233
case EXCCODE_TLBS:
12341234
kvm_debug("TLB ST fault: cause %#x, status %#x, PC: %p, BadVaddr: %#lx\n",
1235-
cause, kvm_read_c0_guest_status(vcpu->arch.cop0), opc,
1235+
cause, kvm_read_c0_guest_status(&vcpu->arch.cop0), opc,
12361236
badvaddr);
12371237

12381238
++vcpu->stat.tlbmiss_st_exits;
@@ -1304,7 +1304,7 @@ static int __kvm_mips_handle_exit(struct kvm_vcpu *vcpu)
13041304
kvm_get_badinstr(opc, vcpu, &inst);
13051305
kvm_err("Exception Code: %d, not yet handled, @ PC: %p, inst: 0x%08x BadVaddr: %#lx Status: %#x\n",
13061306
exccode, opc, inst, badvaddr,
1307-
kvm_read_c0_guest_status(vcpu->arch.cop0));
1307+
kvm_read_c0_guest_status(&vcpu->arch.cop0));
13081308
kvm_arch_vcpu_dump_regs(vcpu);
13091309
run->exit_reason = KVM_EXIT_INTERNAL_ERROR;
13101310
ret = RESUME_HOST;
@@ -1377,7 +1377,7 @@ int noinstr kvm_mips_handle_exit(struct kvm_vcpu *vcpu)
13771377
/* Enable FPU for guest and restore context */
13781378
void kvm_own_fpu(struct kvm_vcpu *vcpu)
13791379
{
1380-
struct mips_coproc *cop0 = vcpu->arch.cop0;
1380+
struct mips_coproc *cop0 = &vcpu->arch.cop0;
13811381
unsigned int sr, cfg5;
13821382

13831383
preempt_disable();
@@ -1421,7 +1421,7 @@ void kvm_own_fpu(struct kvm_vcpu *vcpu)
14211421
/* Enable MSA for guest and restore context */
14221422
void kvm_own_msa(struct kvm_vcpu *vcpu)
14231423
{
1424-
struct mips_coproc *cop0 = vcpu->arch.cop0;
1424+
struct mips_coproc *cop0 = &vcpu->arch.cop0;
14251425
unsigned int sr, cfg5;
14261426

14271427
preempt_disable();

arch/mips/kvm/stats.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ void kvm_mips_dump_stats(struct kvm_vcpu *vcpu)
5454
kvm_info("\nKVM VCPU[%d] COP0 Access Profile:\n", vcpu->vcpu_id);
5555
for (i = 0; i < N_MIPS_COPROC_REGS; i++) {
5656
for (j = 0; j < N_MIPS_COPROC_SEL; j++) {
57-
if (vcpu->arch.cop0->stat[i][j])
57+
if (vcpu->arch.cop0.stat[i][j])
5858
kvm_info("%s[%d]: %lu\n", kvm_cop0_str[i], j,
59-
vcpu->arch.cop0->stat[i][j]);
59+
vcpu->arch.cop0.stat[i][j]);
6060
}
6161
}
6262
#endif

arch/mips/kvm/trace.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -322,11 +322,11 @@ TRACE_EVENT_FN(kvm_guest_mode_change,
322322
),
323323

324324
TP_fast_assign(
325-
__entry->epc = kvm_read_c0_guest_epc(vcpu->arch.cop0);
325+
__entry->epc = kvm_read_c0_guest_epc(&vcpu->arch.cop0);
326326
__entry->pc = vcpu->arch.pc;
327-
__entry->badvaddr = kvm_read_c0_guest_badvaddr(vcpu->arch.cop0);
328-
__entry->status = kvm_read_c0_guest_status(vcpu->arch.cop0);
329-
__entry->cause = kvm_read_c0_guest_cause(vcpu->arch.cop0);
327+
__entry->badvaddr = kvm_read_c0_guest_badvaddr(&vcpu->arch.cop0);
328+
__entry->status = kvm_read_c0_guest_status(&vcpu->arch.cop0);
329+
__entry->cause = kvm_read_c0_guest_cause(&vcpu->arch.cop0);
330330
),
331331

332332
TP_printk("EPC: 0x%08lx PC: 0x%08lx Status: 0x%08x Cause: 0x%08x BadVAddr: 0x%08lx",

0 commit comments

Comments
 (0)