Skip to content
  • Kir Kolyshkin's avatar
    391bdbe4
    zdtm/grow_map: fix test failure for clang · 391bdbe4
    Kir Kolyshkin authored
    
    
    When this code is compiled by clang, it optimizes two byte writes into
    one word write, like this:
    
    >        fake_grow_down[0] = 'c';
    >        *(fake_grow_down - 1) = 'b';
    > 401b60:       66 41 c7 46 ff 62 63    movw   $0x6362,-0x1(%r14)
    
    This is incorrect, as the stack is supposed to grow page by page,
    so we need to touch one page then another, i.e. the order is important.
    
    To fix, let's use volatile pointer. After this change, the following
    (correct) code is generated:
    
    >        *p-- = 'c';
    >   401b60:       41 c6 06 63             movb   $0x63,(%r14)
    >        *p = 'b';
    >   401b64:       41 c6 46 ff 62          movb   $0x62,-0x1(%r14)
    
    [v2: same fix for another similar place]
    
    Cc: Andrei Vagin <avagin@virtuozzo.com>
    Signed-off-by: default avatarKir Kolyshkin <kir@openvz.org>
    Acked-by: default avatarAndrei Vagin <avagin@virtuozzo.com>
    Signed-off-by: default avatarPavel Emelyanov <xemul@virtuozzo.com>
    391bdbe4
    zdtm/grow_map: fix test failure for clang
    Kir Kolyshkin authored
    
    
    When this code is compiled by clang, it optimizes two byte writes into
    one word write, like this:
    
    >        fake_grow_down[0] = 'c';
    >        *(fake_grow_down - 1) = 'b';
    > 401b60:       66 41 c7 46 ff 62 63    movw   $0x6362,-0x1(%r14)
    
    This is incorrect, as the stack is supposed to grow page by page,
    so we need to touch one page then another, i.e. the order is important.
    
    To fix, let's use volatile pointer. After this change, the following
    (correct) code is generated:
    
    >        *p-- = 'c';
    >   401b60:       41 c6 06 63             movb   $0x63,(%r14)
    >        *p = 'b';
    >   401b64:       41 c6 46 ff 62          movb   $0x62,-0x1(%r14)
    
    [v2: same fix for another similar place]
    
    Cc: Andrei Vagin <avagin@virtuozzo.com>
    Signed-off-by: default avatarKir Kolyshkin <kir@openvz.org>
    Acked-by: default avatarAndrei Vagin <avagin@virtuozzo.com>
    Signed-off-by: default avatarPavel Emelyanov <xemul@virtuozzo.com>
Loading