The OpenNET Project / Index page

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



"Линус Торвальдс предложил прекратить поддержку CPU i486 в ядре Linux"
Версия для распечатки Пред. тема | След. тема
Форум Разговоры, обсуждение новостей
Исходное сообщение [ Отслеживать ]
Подсказка: Для слежения за появлением новых сообщений в нити, нажмите "Проследить за развитием треда".
. "Линус Торвальдс предложил прекратить поддержку CPU i486 в яд..." +1 +/
Сообщение от n00by (ok), 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)
;


Ответить | Правка | Наверх | Cообщить модератору

Оглавление
Линус Торвальдс предложил прекратить поддержку CPU i486 в ядре Linux, opennews, 24-Окт-22, 12:21  [смотреть все]
Форумы | Темы | Пред. тема | След. тема



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

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