~mpu/qbe

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
3 2

[PATCH] Revert "revert 5af33410"

Details
Message ID
<20240419135957.35048-2-w@bunny.rocks>
DKIM signature
pass
Download raw message
Patch: +2 -1
This reverts commit 4bc4c9584a13736c20855cdea2203d3bd0a259a3.

We can re-enable BTI now, since the stock `as` in OpenBSD 7.5 seems to
support it:

    qbe $ ./qbe test/tls.ssa > /tmp/tls.s
    qbe $ grep endbr64 /tmp/tls.s | uniq -c
       6    endbr64
    qbe $ as /tmp/tls.s -o /tmp/tls.o
    qbe $ ls -al /tmp/tls.o
    -rw-r--r--  1 w  wheel  2312 Apr 19 06:57 /tmp/tls.o

isel4.ssa and tls.ssa currently fail with SIGILL on my machine. This
commit fixes that.
---
 amd64/emit.c | 2 +-
 arm64/emit.c | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/amd64/emit.c b/amd64/emit.c
index 9636209..65fc9dc 100644
--- a/amd64/emit.c
+++ b/amd64/emit.c
@@ -581,7 +581,7 @@ amd64_emitfn(Fn *fn, FILE *f)
	uint64_t fs;

	emitfnlnk(fn->name, &fn->lnk, f);
	fputs("\tpushq %rbp\n\tmovq %rsp, %rbp\n", f);
	fputs("\tendbr64\n\tpushq %rbp\n\tmovq %rsp, %rbp\n", f);
	fs = framesz(fn);
	if (fs)
		fprintf(f, "\tsubq $%"PRIu64", %%rsp\n", fs);
diff --git a/arm64/emit.c b/arm64/emit.c
index 990d839..6363271 100644
--- a/arm64/emit.c
+++ b/arm64/emit.c
@@ -514,6 +514,7 @@ arm64_emitfn(Fn *fn, FILE *out)
	if (T.apple)
		e->fn->lnk.align = 4;
	emitfnlnk(e->fn->name, &e->fn->lnk, e->f);
	fputs("\thint\t#34\n", e->f);
	framelayout(e);

	if (e->fn->vararg && !T.apple) {
-- 
2.44.0
Details
Message ID
<23d2eb61-9072-4547-ab72-ccf42e4f38d0@app.fastmail.com>
In-Reply-To
<20240419135957.35048-2-w@bunny.rocks> (view parent)
DKIM signature
pass
Download raw message
On Fri, Apr 19, 2024, at 15:59, Chenguang Wang wrote:
> This reverts commit 4bc4c9584a13736c20855cdea2203d3bd0a259a3.
>
> We can re-enable BTI now, since the stock `as` in OpenBSD 7.5 seems to
> support it:
>
>     qbe $ ./qbe test/tls.ssa > /tmp/tls.s
>     qbe $ grep endbr64 /tmp/tls.s | uniq -c
>        6    endbr64
>     qbe $ as /tmp/tls.s -o /tmp/tls.o
>     qbe $ ls -al /tmp/tls.o
>     -rw-r--r--  1 w  wheel  2312 Apr 19 06:57 /tmp/tls.o
>
> isel4.ssa and tls.ssa currently fail with SIGILL on my machine. This
> commit fixes that.

Hi, do you think we could use .cfi_startproc uniformly across
all targets and let the assembler emit the right instructions?
Details
Message ID
<84519355-a69f-41a0-9147-15cc707bde94@app.fastmail.com>
In-Reply-To
<23d2eb61-9072-4547-ab72-ccf42e4f38d0@app.fastmail.com> (view parent)
DKIM signature
pass
Download raw message
I don't think so:

    qbe $ ./qbe test/tls.ssa | tail -n17
    
    .text
    xvalcnt:
            .cfi_startproc
            pushq %rbp
            movq %rsp, %rbp
            movq %fs:0, %rax
            leaq x@tpoff(%rax), %rax
            movl (%rax, %rdi, 4), %eax
            leave
            ret
    .type xvalcnt, @function
    .size xvalcnt, .-xvalcnt
            .cfi_endproc
    /* end function xvalcnt */
    
    .section .note.GNU-stack,"",@progbits

    qbe $ ./tools/test.sh test/tls.ssa
    tls.ssa...                                   --- -      Sun Apr 28 15:53:11 2024
    +++ /tmp/qbe.zzzz.out   Sun Apr 28 15:53:11 2024
    @@ -0,0 +1,6 @@
    +i0==42
    +i1==402653226
    +*(x+0)==1
    +*(x+4)==2
    +*(x+8)==3
    +*(x+12)==4
    Illegal instruction 
    [output fail]

Same error as without .cfi_{start,end}proc.
If code size is a concern, maybe emit endbr64 on OpenBSD only?

On Sat, Apr 27, 2024, at 1:42 AM, Quentin Carbonneaux wrote:
> On Fri, Apr 19, 2024, at 15:59, Chenguang Wang wrote:
>> This reverts commit 4bc4c9584a13736c20855cdea2203d3bd0a259a3.
>>
>> We can re-enable BTI now, since the stock `as` in OpenBSD 7.5 seems to
>> support it:
>>
>>     qbe $ ./qbe test/tls.ssa > /tmp/tls.s
>>     qbe $ grep endbr64 /tmp/tls.s | uniq -c
>>        6    endbr64
>>     qbe $ as /tmp/tls.s -o /tmp/tls.o
>>     qbe $ ls -al /tmp/tls.o
>>     -rw-r--r--  1 w  wheel  2312 Apr 19 06:57 /tmp/tls.o
>>
>> isel4.ssa and tls.ssa currently fail with SIGILL on my machine. This
>> commit fixes that.
>
> Hi, do you think we could use .cfi_startproc uniformly across
> all targets and let the assembler emit the right instructions?
Details
Message ID
<5079daac-3b63-4ab9-a6aa-99ab7fe16923@app.fastmail.com>
In-Reply-To
<84519355-a69f-41a0-9147-15cc707bde94@app.fastmail.com> (view parent)
DKIM signature
pass
Download raw message
Cool, that's done now.
Reply to thread Export thread (mbox)