Skip to content

Commit 21e6075

Browse files
committed
Merge tag 'kvm-riscv-fixes-6.1-1' of https://github.com/kvm-riscv/linux into HEAD
KVM/riscv fixes for 6.1, take #1 - Fix compilation without RISCV_ISA_ZICBOM - Fix kvm_riscv_vcpu_timer_pending() for Sstc
2 parents ebccb53 + cea8896 commit 21e6075

File tree

6 files changed

+57
-51
lines changed

6 files changed

+57
-51
lines changed

arch/riscv/include/asm/cacheflush.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,8 @@ void flush_icache_mm(struct mm_struct *mm, bool local);
4242

4343
#endif /* CONFIG_SMP */
4444

45-
/*
46-
* The T-Head CMO errata internally probe the CBOM block size, but otherwise
47-
* don't depend on Zicbom.
48-
*/
4945
extern unsigned int riscv_cbom_block_size;
50-
#ifdef CONFIG_RISCV_ISA_ZICBOM
5146
void riscv_init_cbom_blocksize(void);
52-
#else
53-
static inline void riscv_init_cbom_blocksize(void) { }
54-
#endif
5547

5648
#ifdef CONFIG_RISCV_DMA_NONCOHERENT
5749
void riscv_noncoherent_supported(void);

arch/riscv/include/asm/kvm_vcpu_timer.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ int kvm_riscv_vcpu_timer_deinit(struct kvm_vcpu *vcpu);
4545
int kvm_riscv_vcpu_timer_reset(struct kvm_vcpu *vcpu);
4646
void kvm_riscv_vcpu_timer_restore(struct kvm_vcpu *vcpu);
4747
void kvm_riscv_guest_timer_init(struct kvm *kvm);
48+
void kvm_riscv_vcpu_timer_sync(struct kvm_vcpu *vcpu);
4849
void kvm_riscv_vcpu_timer_save(struct kvm_vcpu *vcpu);
4950
bool kvm_riscv_vcpu_timer_pending(struct kvm_vcpu *vcpu);
5051

arch/riscv/kvm/vcpu.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -708,6 +708,9 @@ void kvm_riscv_vcpu_sync_interrupts(struct kvm_vcpu *vcpu)
708708
clear_bit(IRQ_VS_SOFT, &v->irqs_pending);
709709
}
710710
}
711+
712+
/* Sync-up timer CSRs */
713+
kvm_riscv_vcpu_timer_sync(vcpu);
711714
}
712715

713716
int kvm_riscv_vcpu_set_interrupt(struct kvm_vcpu *vcpu, unsigned int irq)

arch/riscv/kvm/vcpu_timer.c

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,20 +320,33 @@ void kvm_riscv_vcpu_timer_restore(struct kvm_vcpu *vcpu)
320320
kvm_riscv_vcpu_timer_unblocking(vcpu);
321321
}
322322

323-
void kvm_riscv_vcpu_timer_save(struct kvm_vcpu *vcpu)
323+
void kvm_riscv_vcpu_timer_sync(struct kvm_vcpu *vcpu)
324324
{
325325
struct kvm_vcpu_timer *t = &vcpu->arch.timer;
326326

327327
if (!t->sstc_enabled)
328328
return;
329329

330-
t = &vcpu->arch.timer;
331330
#if defined(CONFIG_32BIT)
332331
t->next_cycles = csr_read(CSR_VSTIMECMP);
333332
t->next_cycles |= (u64)csr_read(CSR_VSTIMECMPH) << 32;
334333
#else
335334
t->next_cycles = csr_read(CSR_VSTIMECMP);
336335
#endif
336+
}
337+
338+
void kvm_riscv_vcpu_timer_save(struct kvm_vcpu *vcpu)
339+
{
340+
struct kvm_vcpu_timer *t = &vcpu->arch.timer;
341+
342+
if (!t->sstc_enabled)
343+
return;
344+
345+
/*
346+
* The vstimecmp CSRs are saved by kvm_riscv_vcpu_timer_sync()
347+
* upon every VM exit so no need to save here.
348+
*/
349+
337350
/* timer should be enabled for the remaining operations */
338351
if (unlikely(!t->init_done))
339352
return;

arch/riscv/mm/cacheflush.c

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* Copyright (C) 2017 SiFive
44
*/
55

6+
#include <linux/of.h>
67
#include <asm/cacheflush.h>
78

89
#ifdef CONFIG_SMP
@@ -86,3 +87,40 @@ void flush_icache_pte(pte_t pte)
8687
flush_icache_all();
8788
}
8889
#endif /* CONFIG_MMU */
90+
91+
unsigned int riscv_cbom_block_size;
92+
EXPORT_SYMBOL_GPL(riscv_cbom_block_size);
93+
94+
void riscv_init_cbom_blocksize(void)
95+
{
96+
struct device_node *node;
97+
unsigned long cbom_hartid;
98+
u32 val, probed_block_size;
99+
int ret;
100+
101+
probed_block_size = 0;
102+
for_each_of_cpu_node(node) {
103+
unsigned long hartid;
104+
105+
ret = riscv_of_processor_hartid(node, &hartid);
106+
if (ret)
107+
continue;
108+
109+
/* set block-size for cbom extension if available */
110+
ret = of_property_read_u32(node, "riscv,cbom-block-size", &val);
111+
if (ret)
112+
continue;
113+
114+
if (!probed_block_size) {
115+
probed_block_size = val;
116+
cbom_hartid = hartid;
117+
} else {
118+
if (probed_block_size != val)
119+
pr_warn("cbom-block-size mismatched between harts %lu and %lu\n",
120+
cbom_hartid, hartid);
121+
}
122+
}
123+
124+
if (probed_block_size)
125+
riscv_cbom_block_size = probed_block_size;
126+
}

arch/riscv/mm/dma-noncoherent.c

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,8 @@
88
#include <linux/dma-direct.h>
99
#include <linux/dma-map-ops.h>
1010
#include <linux/mm.h>
11-
#include <linux/of.h>
12-
#include <linux/of_device.h>
1311
#include <asm/cacheflush.h>
1412

15-
unsigned int riscv_cbom_block_size;
16-
EXPORT_SYMBOL_GPL(riscv_cbom_block_size);
17-
1813
static bool noncoherent_supported;
1914

2015
void arch_sync_dma_for_device(phys_addr_t paddr, size_t size,
@@ -77,42 +72,6 @@ void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size,
7772
dev->dma_coherent = coherent;
7873
}
7974

80-
#ifdef CONFIG_RISCV_ISA_ZICBOM
81-
void riscv_init_cbom_blocksize(void)
82-
{
83-
struct device_node *node;
84-
unsigned long cbom_hartid;
85-
u32 val, probed_block_size;
86-
int ret;
87-
88-
probed_block_size = 0;
89-
for_each_of_cpu_node(node) {
90-
unsigned long hartid;
91-
92-
ret = riscv_of_processor_hartid(node, &hartid);
93-
if (ret)
94-
continue;
95-
96-
/* set block-size for cbom extension if available */
97-
ret = of_property_read_u32(node, "riscv,cbom-block-size", &val);
98-
if (ret)
99-
continue;
100-
101-
if (!probed_block_size) {
102-
probed_block_size = val;
103-
cbom_hartid = hartid;
104-
} else {
105-
if (probed_block_size != val)
106-
pr_warn("cbom-block-size mismatched between harts %lu and %lu\n",
107-
cbom_hartid, hartid);
108-
}
109-
}
110-
111-
if (probed_block_size)
112-
riscv_cbom_block_size = probed_block_size;
113-
}
114-
#endif
115-
11675
void riscv_noncoherent_supported(void)
11776
{
11877
WARN(!riscv_cbom_block_size,

0 commit comments

Comments
 (0)