Changeset 8b420fa in mainline


Ignore:
Timestamp:
2016-06-08T21:41:43Z (8 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
741b2fb1
Parents:
7510326
Message:

Make explicitly sure the userspace window buffer is properly aligned

Do not rely on the implementation of kernel malloc() to assure this.
Instead, create a dedicated slab cache with the proper alignment for
its objects and allocate UWB's from there.

Location:
kernel/arch/sparc64
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/sparc64/include/arch/proc/thread.h

    r7510326 r8b420fa  
    3838#include <typedefs.h>
    3939#include <arch/arch.h>
     40#include <mm/slab.h>
     41
     42extern slab_cache_t *uwb_cache;
    4043
    4144typedef struct {
  • kernel/arch/sparc64/include/arch/trap/regwin.h

    r7510326 r8b420fa  
    7777#define UWB_SIZE        ((NWINDOWS - 1) * STACK_WINDOW_SAVE_AREA_SIZE)
    7878#define UWB_ALIGNMENT   1024
    79 #define UWB_ASIZE       ALIGN_UP(UWB_SIZE, UWB_ALIGNMENT)
    8079
    8180#ifdef __ASM__
  • kernel/arch/sparc64/src/proc/thread.c

    r7510326 r8b420fa  
    3939#include <align.h>
    4040
     41slab_cache_t *uwb_cache = NULL;
     42
    4143void thr_constructor_arch(thread_t *t)
    4244{
     
    5557                 * belonging to a killed thread.
    5658                 */
    57                 free((uint8_t *) ALIGN_DOWN(uw_buf, UWB_ALIGNMENT));
     59                slab_free(uwb_cache, (uint8_t *) ALIGN_DOWN(uw_buf,
     60                    UWB_ALIGNMENT));
    5861        }
    5962}
     
    6770                 * returned from the slab allocator doesn't have any.
    6871                 */
    69                 t->arch.uspace_window_buffer = malloc(UWB_ASIZE, 0);
     72                t->arch.uspace_window_buffer = slab_alloc(uwb_cache, 0);
    7073        } else {
    7174                uintptr_t uw_buf = (uintptr_t) t->arch.uspace_window_buffer;
     
    7679                 */
    7780                t->arch.uspace_window_buffer = (uint8_t *) ALIGN_DOWN(uw_buf,
    78                     UWB_ASIZE);
     81                    UWB_ALIGNMENT);
    7982        }
    8083}
  • kernel/arch/sparc64/src/sparc64.c

    r7510326 r8b420fa  
    3535#include <arch.h>
    3636#include <arch/arch.h>
     37#include <mm/slab.h>
     38#include <config.h>
     39#include <arch/proc/thread.h>
     40#include <arch/trap/regwin.h>
     41#include <debug.h>
    3742
    3843#define SPARC64_ARCH_OP(op)     ARCH_STRUCT_OP(sparc64_ops, op)
     
    6267{
    6368        SPARC64_ARCH_OP(post_mm_init);
     69
     70        if (config.cpu_active == 1) {
     71                STATIC_ASSERT(UWB_SIZE <= UWB_ALIGNMENT);
     72                /* Create slab cache for the userspace window buffers */
     73                uwb_cache = slab_cache_create("uwb_cache", UWB_SIZE,
     74                    UWB_ALIGNMENT, NULL, NULL, SLAB_CACHE_MAGDEFERRED);
     75        }
    6476}
    6577
Note: See TracChangeset for help on using the changeset viewer.