Fix paffinity_linux_module.c. The set and get functions transferred cpu
masks between the mask argument and a local PLPA mask. There were three problems: 1) The "get" function computed the number of bits as sizeof(mask), which is the size of the pointer to the mask rather than the mask itself. So, only 4 bits were copied with m32 and 8 bits with m64. There are actually 1024 bits. 2) The "get" and "set" functions both copied a number of bits computed from the sizeof() mask, but sizeof() reports the number of bytes. We have to multiply by 8 to get the number of bits. 3) These two functions check to make sure tha the mask argument is not bigger than the PLPA mask. But, the set function copies a number of bits in the PLPA mask, which is conceivably greater than the number of bits in the mask argument. So, accesses to the mask argument may overrun that argument. Problems 1 and 2 meant that one would encounter errors when the number of cores exceeded 4 (with -m32) or 8 (with -m64). Problem 3 probably caused no errors. This commit was SVN r21993.
Этот коммит содержится в:
родитель
8da3aa8d5c
Коммит
67bac2fe31
@ -178,7 +178,7 @@ static int linux_module_set(opal_paffinity_base_cpu_set_t mask)
|
|||||||
return OPAL_ERR_BAD_PARAM;
|
return OPAL_ERR_BAD_PARAM;
|
||||||
} else {
|
} else {
|
||||||
PLPA_CPU_ZERO(&plpa_mask);
|
PLPA_CPU_ZERO(&plpa_mask);
|
||||||
for (i = 0; i < sizeof(plpa_mask) ; i++) {
|
for (i = 0; i < 8 * sizeof(mask) ; i++) {
|
||||||
if (PLPA_CPU_ISSET(i,&mask)) {
|
if (PLPA_CPU_ISSET(i,&mask)) {
|
||||||
PLPA_CPU_SET(i,&plpa_mask);
|
PLPA_CPU_SET(i,&plpa_mask);
|
||||||
}
|
}
|
||||||
@ -210,7 +210,7 @@ static int linux_module_get(opal_paffinity_base_cpu_set_t *mask)
|
|||||||
if (0 != opal_paffinity_linux_plpa_sched_getaffinity(getpid(), sizeof(plpa_mask), &plpa_mask)) {
|
if (0 != opal_paffinity_linux_plpa_sched_getaffinity(getpid(), sizeof(plpa_mask), &plpa_mask)) {
|
||||||
return OPAL_ERR_IN_ERRNO;
|
return OPAL_ERR_IN_ERRNO;
|
||||||
}
|
}
|
||||||
for (i = 0; i < sizeof(mask); i++) {
|
for (i = 0; i < 8 * sizeof(*mask); i++) {
|
||||||
if (PLPA_CPU_ISSET(i,&plpa_mask)) {
|
if (PLPA_CPU_ISSET(i,&plpa_mask)) {
|
||||||
PLPA_CPU_SET(i,mask);
|
PLPA_CPU_SET(i,mask);
|
||||||
}
|
}
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user