softirq: move softirq from hv_main to interrupt context

softirq shouldn't be bounded to vcpu thread. One issue for this
is shell (based on timer) can't work if we don't start any guest.

This change also is trying best to make softirq handler running
with irq enabled.

Also update the irq disable/enabel in vmexit handler to align
with the usage in vcpu_thread.

Tracked-On: #3387
Signed-off-by: Yin Fengwei <fengwei.yin@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
This commit is contained in:
Yin, Fengwei
2019-07-09 18:02:55 +08:00
committed by wenlingz
parent cb9866bc6c
commit 11e67f1c4a
5 changed files with 31 additions and 8 deletions

View File

@@ -28,11 +28,7 @@ void vcpu_thread(struct sched_object *obj)
}
if (!is_lapic_pt_enabled(vcpu)) {
/* handle pending softirq when irq enable*/
do_softirq();
CPU_IRQ_DISABLE();
/* handle risk softirq when disabling irq*/
do_softirq();
}
/* Don't open interrupt window between here and vmentry */

View File

@@ -32,9 +32,8 @@ void fire_softirq(uint16_t nr)
bitmap_set_lock(nr, &per_cpu(softirq_pending, get_pcpu_id()));
}
void do_softirq(void)
static void do_softirq_internal(uint16_t cpu_id)
{
uint16_t cpu_id = get_pcpu_id();
volatile uint64_t *softirq_pending_bitmap =
&per_cpu(softirq_pending, cpu_id);
uint16_t nr = ffs64(*softirq_pending_bitmap);
@@ -45,3 +44,22 @@ void do_softirq(void)
nr = ffs64(*softirq_pending_bitmap);
}
}
/*
* @pre: this function will only be called with irq disabled
*/
void do_softirq(void)
{
uint16_t cpu_id = get_pcpu_id();
if (per_cpu(softirq_servicing, cpu_id) == 0U) {
per_cpu(softirq_servicing, cpu_id) = 1U;
CPU_IRQ_ENABLE();
do_softirq_internal(cpu_id);
CPU_IRQ_DISABLE();
do_softirq_internal(cpu_id);
per_cpu(softirq_servicing, cpu_id) = 0U;
}
}