Skip to content

Commit 9bc60f7

Browse files
committed
Merge tag 'kvm-riscv-fixes-6.9-1' of https://github.com/kvm-riscv/linux into HEAD
KVM/riscv fixes for 6.9, take #1 - Fix spelling mistake in arch_timer selftest - Remove redundant semicolon in num_isa_ext_regs() - Fix APLIC setipnum_le/be write emulation - Fix APLIC in_clrip[x] read emulation
2 parents 52b761b + 8e936e9 commit 9bc60f7

File tree

4 files changed

+34
-9
lines changed

4 files changed

+34
-9
lines changed

arch/riscv/kvm/aia_aplic.c

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,21 @@ static void aplic_write_pending(struct aplic *aplic, u32 irq, bool pending)
137137
raw_spin_lock_irqsave(&irqd->lock, flags);
138138

139139
sm = irqd->sourcecfg & APLIC_SOURCECFG_SM_MASK;
140-
if (!pending &&
141-
((sm == APLIC_SOURCECFG_SM_LEVEL_HIGH) ||
142-
(sm == APLIC_SOURCECFG_SM_LEVEL_LOW)))
140+
if (sm == APLIC_SOURCECFG_SM_INACTIVE)
143141
goto skip_write_pending;
144142

143+
if (sm == APLIC_SOURCECFG_SM_LEVEL_HIGH ||
144+
sm == APLIC_SOURCECFG_SM_LEVEL_LOW) {
145+
if (!pending)
146+
goto skip_write_pending;
147+
if ((irqd->state & APLIC_IRQ_STATE_INPUT) &&
148+
sm == APLIC_SOURCECFG_SM_LEVEL_LOW)
149+
goto skip_write_pending;
150+
if (!(irqd->state & APLIC_IRQ_STATE_INPUT) &&
151+
sm == APLIC_SOURCECFG_SM_LEVEL_HIGH)
152+
goto skip_write_pending;
153+
}
154+
145155
if (pending)
146156
irqd->state |= APLIC_IRQ_STATE_PENDING;
147157
else
@@ -187,16 +197,31 @@ static void aplic_write_enabled(struct aplic *aplic, u32 irq, bool enabled)
187197

188198
static bool aplic_read_input(struct aplic *aplic, u32 irq)
189199
{
190-
bool ret;
191-
unsigned long flags;
200+
u32 sourcecfg, sm, raw_input, irq_inverted;
192201
struct aplic_irq *irqd;
202+
unsigned long flags;
203+
bool ret = false;
193204

194205
if (!irq || aplic->nr_irqs <= irq)
195206
return false;
196207
irqd = &aplic->irqs[irq];
197208

198209
raw_spin_lock_irqsave(&irqd->lock, flags);
199-
ret = (irqd->state & APLIC_IRQ_STATE_INPUT) ? true : false;
210+
211+
sourcecfg = irqd->sourcecfg;
212+
if (sourcecfg & APLIC_SOURCECFG_D)
213+
goto skip;
214+
215+
sm = sourcecfg & APLIC_SOURCECFG_SM_MASK;
216+
if (sm == APLIC_SOURCECFG_SM_INACTIVE)
217+
goto skip;
218+
219+
raw_input = (irqd->state & APLIC_IRQ_STATE_INPUT) ? 1 : 0;
220+
irq_inverted = (sm == APLIC_SOURCECFG_SM_LEVEL_LOW ||
221+
sm == APLIC_SOURCECFG_SM_EDGE_FALL) ? 1 : 0;
222+
ret = !!(raw_input ^ irq_inverted);
223+
224+
skip:
200225
raw_spin_unlock_irqrestore(&irqd->lock, flags);
201226

202227
return ret;

arch/riscv/kvm/vcpu_onereg.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -986,7 +986,7 @@ static int copy_isa_ext_reg_indices(const struct kvm_vcpu *vcpu,
986986

987987
static inline unsigned long num_isa_ext_regs(const struct kvm_vcpu *vcpu)
988988
{
989-
return copy_isa_ext_reg_indices(vcpu, NULL);;
989+
return copy_isa_ext_reg_indices(vcpu, NULL);
990990
}
991991

992992
static int copy_sbi_ext_reg_indices(struct kvm_vcpu *vcpu, u64 __user *uindices)

tools/testing/selftests/kvm/aarch64/arch_timer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ static void guest_run_stage(struct test_vcpu_shared_data *shared_data,
136136
irq_iter = READ_ONCE(shared_data->nr_iter);
137137
__GUEST_ASSERT(config_iter + 1 == irq_iter,
138138
"config_iter + 1 = 0x%x, irq_iter = 0x%x.\n"
139-
" Guest timer interrupt was not trigged within the specified\n"
139+
" Guest timer interrupt was not triggered within the specified\n"
140140
" interval, try to increase the error margin by [-e] option.\n",
141141
config_iter + 1, irq_iter);
142142
}

tools/testing/selftests/kvm/riscv/arch_timer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ static void guest_run(struct test_vcpu_shared_data *shared_data)
6060
irq_iter = READ_ONCE(shared_data->nr_iter);
6161
__GUEST_ASSERT(config_iter + 1 == irq_iter,
6262
"config_iter + 1 = 0x%x, irq_iter = 0x%x.\n"
63-
" Guest timer interrupt was not trigged within the specified\n"
63+
" Guest timer interrupt was not triggered within the specified\n"
6464
" interval, try to increase the error margin by [-e] option.\n",
6565
config_iter + 1, irq_iter);
6666
}

0 commit comments

Comments
 (0)