Changeset bf05c74 in mainline


Ignore:
Timestamp:
2018-10-24T17:59:50Z (6 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
5c38838, 889cdb1
Parents:
cfdeedc
Message:

Fix kernel ubsan

Location:
kernel
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • kernel/genarch/src/acpi/acpi.c

    rcfdeedc rbf05c74  
    4343#include <mm/km.h>
    4444#include <log.h>
     45#include <mem.h>
    4546
    4647#define RSDP_SIGNATURE      "RSD PTR "
     
    170171}
    171172
     173static uint8_t *search_rsdp(uint8_t *base, size_t len)
     174{
     175        for (size_t i = 0; i < len; i += 16) {
     176                if (memcmp(&base[i], RSDP_SIGNATURE, sizeof(RSDP_SIGNATURE)) == 0 &&
     177                    rsdp_check(&base[i]))
     178                        return &base[i];
     179        }
     180
     181        return NULL;
     182}
     183
    172184void acpi_init(void)
    173185{
    174         uint8_t *addr[2] = { NULL, (uint8_t *) PA2KA(0xe0000) };
    175         unsigned int i;
    176         unsigned int j;
    177         unsigned int length[2] = { 1024, 128 * 1024 };
    178         uint64_t *sig = (uint64_t *) RSDP_SIGNATURE;
    179 
    180186        /*
    181187         * Find Root System Description Pointer
     
    184190         */
    185191
    186         addr[0] = (uint8_t *) PA2KA(ebda);
    187         for (i = (ebda ? 0 : 1); i < 2; i++) {
    188                 for (j = 0; j < length[i]; j += 16) {
    189                         if ((*((uint64_t *) &addr[i][j]) == *sig) &&
    190                             (rsdp_check(&addr[i][j]))) {
    191                                 acpi_rsdp = (struct acpi_rsdp *) &addr[i][j];
    192                                 goto rsdp_found;
    193                         }
    194                 }
    195         }
    196 
    197         return;
    198 
    199 rsdp_found:
     192        uint8_t *rsdp = NULL;
     193
     194        if (ebda)
     195                rsdp = search_rsdp((uint8_t *) PA2KA(ebda), 1024);
     196
     197        if (!rsdp)
     198                rsdp = search_rsdp((uint8_t *) PA2KA(0xe0000), 128 * 1024);
     199
     200        if (!rsdp)
     201                return;
     202
     203        acpi_rsdp = (struct acpi_rsdp *) rsdp;
     204
    200205        LOG("%p: ACPI Root System Description Pointer", acpi_rsdp);
    201206
  • kernel/generic/src/lib/ubsan.c

    rcfdeedc rbf05c74  
    3434};
    3535
     36struct type_mismatch_data_v1 {
     37        struct source_location loc;
     38        struct type_descriptor *type;
     39        unsigned char log_alignment;
     40        unsigned char type_check_kind;
     41};
     42
    3643struct overflow_data {
    3744        struct source_location loc;
     
    7279        struct source_location loc;
    7380        struct source_location attr_loc;
     81};
     82
     83struct pointer_overflow_data {
     84        struct source_location loc;
    7485};
    7586
     
    8091 */
    8192void __ubsan_handle_type_mismatch(struct type_mismatch_data *data, unsigned long ptr);
     93void __ubsan_handle_type_mismatch_v1(struct type_mismatch_data_v1 *data, unsigned long ptr);
    8294void __ubsan_handle_add_overflow(struct overflow_data *data, unsigned long lhs, unsigned long rhs);
    8395void __ubsan_handle_sub_overflow(struct overflow_data *data, unsigned long lhs, unsigned long rhs);
     
    97109#endif
    98110void __ubsan_handle_nonnull_return(struct nonnull_return_data *data);
     111void __ubsan_handle_nonnull_return_v1(struct nonnull_return_data *data,
     112    struct source_location *loc);
     113void __ubsan_handle_pointer_overflow(struct pointer_overflow_data *data,
     114    unsigned long base, unsigned long result);
    99115
    100116static void print_loc(const char *func, struct source_location *loc)
     
    218234        ubsan_panic();
    219235}
     236
     237void __ubsan_handle_nonnull_return_v1(struct nonnull_return_data *data,
     238    struct source_location *loc)
     239{
     240        print_loc(__func__, &data->loc);
     241        ubsan_panic();
     242}
     243
     244void __ubsan_handle_pointer_overflow(struct pointer_overflow_data *data,
     245    unsigned long base, unsigned long result)
     246{
     247        print_loc(__func__, &data->loc);
     248        ubsan_panic();
     249}
     250
     251void __ubsan_handle_type_mismatch_v1(struct type_mismatch_data_v1 *data,
     252    unsigned long ptr)
     253{
     254        print_loc(__func__, &data->loc);
     255        ubsan_panic();
     256}
Note: See TracChangeset for help on using the changeset viewer.