Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Tue, 24 May 2022 17:08:21 +0800
From: 王洪亮 <>
Subject: Re: add loongarch64 port v3

在 2022/5/21 下午4:22, Markus Wichmann 写道:
>>> I'm also not clear on how
>>> specifying the alignment here helps since any object created in a way
>>> that the alignment would affect cannot have the FAM present.
>> the __aligned__(16)  here used to save 128bit vector later.
> But it has no effect, right? The array member is offset an integer
> multiple of sixteen bytes from the start of the structure, so it is
> already aligned with respect to that, and the declaration adds no
> further padding (and if it did, common style in both Linux and musl is
> to explicate the padding). And the pointer to the structure comes from
> the kernel.

if no __aligned__(16),the struct sigcontext is 8 bytes align,even if the 

is offset an integer multiple of 16 bytes from the start of struct 
sigcontext,it can only

ensure the extcontext[] is 8 bytes align. (just only when sigcontext is 
16 bytes align,

extcontext[] can meet 16 bytes align.)

> The only thing this alignment directive does is raise the alignment
> requirement of the structure up to sixteen, but that only possibly
> matters for variables of the structure type, be they automatic or
> program life time. But from here it is hard to see why the alignment
> should matter in either of those cases, since those would only possibly
> be local buffers of the kernel-provided mcontext. And the kernel
> provides the mcontext already with all the alignment it needs. I am not
> aware of any kernel API that receives a user provided mcontext. And even
> if there was one, the kernel would have to copy it into kernel space
> before doing anything with it, anyway.

this not need kernel API, in kernel, if task has pending signal, kernel 
save context

to ucontext(in user stack space), then return to userspace to signal 
handle, from

the third parameter of signal_handler, user can access the ucontext and 

libc and kernel access the same ucontext in user stack space.

void signal_handler (int sig, siginfo_t *info, void *ctx) {

         ucontext_t *uc = ctx;

mcontext_t *mc = ctx->uc_mcontext;


> And, BTW, if the alignment really is needed on the mcontext_t itself, it
> might be better to put the alignment tag on the type, not one of the
> members.

we need extcontext[] 16 bytes align for 128bit vector access, if put the
alignment on mcontext_t itself,although it can also meet the 16 bytes align
requirements of extcontext[] (the offset is an integer multiple of 16 bytes
from the start of struct sigcontext),the meaning is not clear.

> Ciao,
> Markus

Content of type "text/html" skipped

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.