HV: add pcpu id check before send IPI

to avoid send IPI to self, also improve the related code:
1. get_cpu_id is uint16_t now
2. MISRA-C requirement. like add {}

Signed-off-by: Minggui Cao <minggui.cao@intel.com>
Reviewed-by: Jason Chen CJ <jason.cj.chen@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
Minggui Cao 2018-08-10 14:12:16 +08:00 committed by lijinxia
parent c25a62e5b0
commit 462284fa7d
3 changed files with 9 additions and 4 deletions

View File

@ -104,8 +104,9 @@ void vcpu_make_request(struct vcpu *vcpu, uint16_t eventid)
* scheduling, we need change here to determine it target vcpu is * scheduling, we need change here to determine it target vcpu is
* VMX non-root or root mode * VMX non-root or root mode
*/ */
if ((int)get_cpu_id() != vcpu->pcpu_id) if (get_cpu_id() != vcpu->pcpu_id) {
send_single_ipi(vcpu->pcpu_id, VECTOR_NOTIFY_VCPU); send_single_ipi(vcpu->pcpu_id, VECTOR_NOTIFY_VCPU);
}
} }
static int vcpu_do_pending_event(struct vcpu *vcpu) static int vcpu_do_pending_event(struct vcpu *vcpu)

View File

@ -157,7 +157,7 @@ int vmexit_handler(struct vcpu *vcpu)
uint16_t basic_exit_reason; uint16_t basic_exit_reason;
int ret; int ret;
if ((int)get_cpu_id() != vcpu->pcpu_id) { if (get_cpu_id() != vcpu->pcpu_id) {
pr_fatal("vcpu is not running on its pcpu!"); pr_fatal("vcpu is not running on its pcpu!");
return -EINVAL; return -EINVAL;
} }

View File

@ -101,7 +101,9 @@ void make_reschedule_request(struct vcpu *vcpu)
struct sched_context *ctx = &per_cpu(sched_ctx, vcpu->pcpu_id); struct sched_context *ctx = &per_cpu(sched_ctx, vcpu->pcpu_id);
bitmap_set_lock(NEED_RESCHEDULE, &ctx->flags); bitmap_set_lock(NEED_RESCHEDULE, &ctx->flags);
if (get_cpu_id() != vcpu->pcpu_id) {
send_single_ipi(vcpu->pcpu_id, VECTOR_NOTIFY_VCPU); send_single_ipi(vcpu->pcpu_id, VECTOR_NOTIFY_VCPU);
}
} }
int need_reschedule(uint16_t pcpu_id) int need_reschedule(uint16_t pcpu_id)
@ -153,7 +155,9 @@ void make_pcpu_offline(uint16_t pcpu_id)
struct sched_context *ctx = &per_cpu(sched_ctx, pcpu_id); struct sched_context *ctx = &per_cpu(sched_ctx, pcpu_id);
bitmap_set_lock(NEED_OFFLINE, &ctx->flags); bitmap_set_lock(NEED_OFFLINE, &ctx->flags);
if (get_cpu_id() != pcpu_id) {
send_single_ipi(pcpu_id, VECTOR_NOTIFY_VCPU); send_single_ipi(pcpu_id, VECTOR_NOTIFY_VCPU);
}
} }
int need_offline(uint16_t pcpu_id) int need_offline(uint16_t pcpu_id)