The OpenNET Project / Index page

[ новости /+++ | форум | теги | ]



Индекс форумов
Составление сообщения

Исходное сообщение
"Линус Торвальдс предложил прекратить поддержку CPU i486 в яд..."
Отправлено n00by, 27-Окт-22 12:54 
>> Проблема не в том, что этот код «сложен». Следует определить, поддерживает ли
>> процессор инструкцию, и вызвать вот это, если нет. cmpxchg8b используется в
> это делается на этапе _компиляции_

Но код ты показать забыл. Потому что его не видел. И не покажешь. Потому что не увидишь такого. Но мог бы хоть подумать -- если я нашёл один фрагмент, значит, посмотрел и граф вызовов. В общем, не суди других по себе. ;)

«early code in apply_alternatives() replaces @oldinstr with @newinstr»


/*
* Building a kernel capable running on 80386 and 80486. It may be necessary
* to simulate the cmpxchg8b on the 80386 and 80486 CPU.
*/

#define arch_cmpxchg64(ptr, o, n)                \
({                                \
    __typeof__(*(ptr)) __ret;                \
    __typeof__(*(ptr)) __old = (o);                \
    __typeof__(*(ptr)) __new = (n);                \
    alternative_io(LOCK_PREFIX_HERE                \
            "call cmpxchg8b_emu",            \
            "lock; cmpxchg8b (%%esi)" ,        \
               X86_FEATURE_CX8,                \
               "=A" (__ret),                \
               "S" ((ptr)), "0" (__old),        \
               "b" ((unsigned int)__new),        \
               "c" ((unsigned int)(__new>>32))        \
               : "memory");                \
    __ret; })


/* Like alternative_input, but with a single output argument */
#define alternative_io(oldinstr, newinstr, feature, output, input...)    \
    asm_inline volatile (ALTERNATIVE(oldinstr, newinstr, feature)    \
        : output : "i" (0), ## input)

/*
* Define an alternative between two instructions. If @feature is
* present, early code in apply_alternatives() replaces @oldinstr with
* @newinstr. ".skip" directive takes care of proper instruction padding
* in case @newinstr is longer than @oldinstr.
*/

/* alternative assembly primitive: */
#define ALTERNATIVE(oldinstr, newinstr, feature)            \
    OLDINSTR(oldinstr, 1)                        \
    ".pushsection .altinstructions,\"a\"\n"                \
    ALTINSTR_ENTRY(feature, 1)                    \
    ".popsection\n"                            \
    ".pushsection .altinstr_replacement, \"ax\"\n"            \
    ALTINSTR_REPLACEMENT(newinstr, 1)                \
    ".popsection\n"


/*
* Replace instructions with better alternatives for this CPU type. This runs
* before SMP is initialized to avoid SMP problems with self modifying code.
* This implies that asymmetric systems where APs have less capabilities than
* the boot processor are not handled. Tough. Make sure you disable such
* features by hand.
*
* Marked "noinline" to cause control flow change and thus insn cache
* to refetch changed I$ lines.
*/
void __init_or_module noinline apply_alternatives(struct alt_instr *start,
                          struct alt_instr *end)
;


 

Ваше сообщение
Имя*:
EMail:
Для отправки ответов на email укажите знак ! перед адресом, например, [email protected] (!! - не показывать email).
Более тонкая настройка отправки ответов производится в профиле зарегистрированного участника форума.
Заголовок*:
Сообщение*:
  Введите код, изображенный на картинке: КОД
 
При общении не допускается: неуважительное отношение к собеседнику, хамство, унизительное обращение, ненормативная лексика, переход на личности, агрессивное поведение, обесценивание собеседника, провоцирование флейма голословными и заведомо ложными заявлениями. Не отвечайте на сообщения, явно нарушающие правила - удаляются не только сами нарушения, но и все ответы на них. Лог модерирования.



Партнёры:
PostgresPro
Inferno Solutions
Hosting by Hoster.ru
Хостинг:

Закладки на сайте
Проследить за страницей
Created 1996-2024 by Maxim Chirkov
Добавить, Поддержать, Вебмастеру