ia64/xen-unstable

changeset 8973:5bf4d9a9694f

Whenever the slice of a domU is set to 0, sedf_adjdom() sets extraweight
to 0. Later, in desched_extra_dom(), if the extrawight is not set, the
vcpu's score is calculated with this:

/*domain was running in L1 extraq => score is inverse of
utilization and is used somewhat incremental!*/
if ( !inf->extraweight )
/*NB: use fixed point arithmetic with 10 bits*/
inf->score[EXTRA_UTIL_Q] = (inf->period << 10) /
inf->slice;

Which can result in a divide by zero.

This changeset adds a comments and additional sanity check to prevent this
case from crashing Xen.

Signed-off-by: Ryan Harper <ryanh@us.ibm.com>
author kaf24@firebug.cl.cam.ac.uk
date Thu Feb 23 11:31:01 2006 +0100 (2006-02-23)
parents 323d40eefbce
children 0349fb4de335
files xen/common/sched_sedf.c
line diff
     1.1 --- a/xen/common/sched_sedf.c	Thu Feb 23 11:27:35 2006 +0100
     1.2 +++ b/xen/common/sched_sedf.c	Thu Feb 23 11:31:01 2006 +0100
     1.3 @@ -1609,15 +1609,19 @@ static int sedf_adjdom(struct domain *p,
     1.4          else {
     1.5              /*time driven domains*/
     1.6              for_each_vcpu(p, v) {
     1.7 -                /* sanity checking! */
     1.8 -                if(cmd->u.sedf.slice > cmd->u.sedf.period )
     1.9 +                /*
    1.10 +                 * Sanity checking: note that disabling extra weight requires
    1.11 +                 * that we set a non-zero slice.
    1.12 +                 */
    1.13 +                if ( (cmd->u.sedf.slice == 0) ||
    1.14 +                     (cmd->u.sedf.slice > cmd->u.sedf.period) )
    1.15                      return -EINVAL;
    1.16                  EDOM_INFO(v)->weight = 0;
    1.17                  EDOM_INFO(v)->extraweight = 0;
    1.18                  EDOM_INFO(v)->period_orig = 
    1.19 -                    EDOM_INFO(v)->period   = cmd->u.sedf.period;
    1.20 +                    EDOM_INFO(v)->period  = cmd->u.sedf.period;
    1.21                  EDOM_INFO(v)->slice_orig  = 
    1.22 -                    EDOM_INFO(v)->slice    = cmd->u.sedf.slice;
    1.23 +                    EDOM_INFO(v)->slice   = cmd->u.sedf.slice;
    1.24              }
    1.25          }
    1.26          if (sedf_adjust_weights(cmd))