From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id DF3E6C48BF8 for ; Tue, 20 Feb 2024 02:16:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4B70E6B0083; Mon, 19 Feb 2024 21:16:03 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 466D96B0087; Mon, 19 Feb 2024 21:16:03 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 30A426B008C; Mon, 19 Feb 2024 21:16:03 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 1EB7B6B0083 for ; Mon, 19 Feb 2024 21:16:03 -0500 (EST) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id E24AFC0326 for ; Tue, 20 Feb 2024 02:16:02 +0000 (UTC) X-FDA: 81810566964.18.45BC7ED Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.169]) by imf05.hostedemail.com (Postfix) with ESMTP id 07466100013 for ; Tue, 20 Feb 2024 02:16:00 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=linaro.org header.s=google header.b=sCtXP1ta; dmarc=pass (policy=none) header.from=linaro.org; spf=pass (imf05.hostedemail.com: domain of thiago.bauermann@linaro.org designates 209.85.214.169 as permitted sender) smtp.mailfrom=thiago.bauermann@linaro.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1708395361; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=+OAN0Lt5ZKU5YCY2zjENEtHOA9Ppd3OvNfkI0wLPm9E=; b=PEFVGltBqWETkmyugC07Y/EX2NKYm30KOZ9ckCjvWPR3uY1HxsHbmdBnnv+pvJOXC3fX9K mrRiHHxmaMnLRtZnEtyHIMyyk1QB3kIk5oRKraU+XxLnm+6p8x5/PrpIgsz3YciFxs3OpW ASg/JEn/WwBBZFk+QcSRgiJXTswZcX4= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=linaro.org header.s=google header.b=sCtXP1ta; dmarc=pass (policy=none) header.from=linaro.org; spf=pass (imf05.hostedemail.com: domain of thiago.bauermann@linaro.org designates 209.85.214.169 as permitted sender) smtp.mailfrom=thiago.bauermann@linaro.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1708395361; a=rsa-sha256; cv=none; b=nKp/9Jo1q2PSvrLGZxDWzOsSg0FXADTSu7rNkLWPHgXHVtDhZ06HZNi2jrnJPBI4c9ykzd WuORSkIGqREM39kR88/rn+1U5mw0DtaBSlPg+j8PHT00D7P0Nla/b5+xMsrk2IQ2YI8+zU xlvX4mxJmOUcxpBGfHWzsjQ2cnJxemM= Received: by mail-pl1-f169.google.com with SMTP id d9443c01a7336-1dbd32cff0bso16164215ad.0 for ; Mon, 19 Feb 2024 18:16:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708395360; x=1709000160; darn=kvack.org; h=content-transfer-encoding:mime-version:message-id:date:in-reply-to :subject:cc:to:from:user-agent:references:from:to:cc:subject:date :message-id:reply-to; bh=+OAN0Lt5ZKU5YCY2zjENEtHOA9Ppd3OvNfkI0wLPm9E=; b=sCtXP1taSOt4yNxWvktRA9Ivo+nSIvJR9wLYJ2zgXBpYPlA1W0w45CL/Z1CVadDE1w sYlKYp5Mrs+FnnlqTFfSgyMEzA0B2gw6jZ5DThA4Bwt3hefn89eDv8JNkg3tRZxfvSti wUe0VPOb/7G0BotHHxnAUHDVUaF1TpG81BXfImK4UmsBV6qXB1dIj9KMkJH+ySR9b9Pl Lnm+daNd4JI8xbBIqXh1kjMVtX9vGBEZpb1UY8RcDilkDH6d/vySIEcQ4fn6x6I2UuLQ bzR+fVkGweWC0WyB+eXZsfE2ympW5VEr+Cfr7vGaskWvPknVmKK/5JwNVCW0NOjYlHv/ C0iA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708395360; x=1709000160; h=content-transfer-encoding:mime-version:message-id:date:in-reply-to :subject:cc:to:from:user-agent:references:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=+OAN0Lt5ZKU5YCY2zjENEtHOA9Ppd3OvNfkI0wLPm9E=; b=OkbJVkT7r1vpeF7rogGQOgnBgmNledseF0u5wQ2FjWEqZtOK/NXOqYGq762+Mo8F19 vujSQ5OFjRK0vmotDjlSePpYZTi5HrAxrl+WonuCSl/xj8lP5JOwfwANTLIKKDNnG4e3 kyAxbHrzIhYprSi503g5ZlIbfzWaRCY0dZvOL+EyitUys4IH9dF6aKjXPd+j/wg9oJiP vPpMF0/gQy3ELvzVP3ehdBk7sqHva5qLqIT3nOW+/+aByVUe6Fk+uh5rWrVR+ET325Iu 4ngMs4I3ewtnG1ZTR/5ClXBM0bRe9oXOMNnzbx3CcsYAYCrnxKuycV+sVkODdoAdgyRr H57g== X-Forwarded-Encrypted: i=1; AJvYcCXFz9KPCR4WPcEBhubRr6D7aughKFiZStrxVOUc+pPpcHp4QZ0VzmHOAo/yU7Za63L5njA2ScFTidVj0h5lxXj2hKk= X-Gm-Message-State: AOJu0YwKgwt/EiidHgRHQiIIVYV7mqlhCj13loDF+4VnKvpcHvbyZuxV F3u6ZgDVQemJGM1vf6LhKrpOT5NSk0gpvOttgXgwxNIeO73Rf0O0jxQInKmKGeo= X-Google-Smtp-Source: AGHT+IE/HK82k8jF0QyDP8MRiJTDcRIUH+5Nn34RcteS7Lvc7xDUJSIleyKlVy8K/rQ9hjc5E9YxbQ== X-Received: by 2002:a17:902:ea0d:b0:1db:e7a4:90a8 with SMTP id s13-20020a170902ea0d00b001dbe7a490a8mr6006330plg.10.1708395359755; Mon, 19 Feb 2024 18:15:59 -0800 (PST) Received: from localhost ([2804:14d:7e39:8470:a328:9cae:8aed:4821]) by smtp.gmail.com with ESMTPSA id x15-20020a170902ec8f00b001db3efca159sm5042143plg.132.2024.02.19.18.15.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Feb 2024 18:15:59 -0800 (PST) References: <20240203-arm64-gcs-v8-0-c9fec77673ef@kernel.org> <20240203-arm64-gcs-v8-33-c9fec77673ef@kernel.org> User-agent: mu4e 1.10.8; emacs 29.1 From: Thiago Jung Bauermann To: Mark Brown Cc: Catalin Marinas , Will Deacon , Jonathan Corbet , Andrew Morton , Marc Zyngier , Oliver Upton , James Morse , Suzuki K Poulose , Arnd Bergmann , Oleg Nesterov , Eric Biederman , Kees Cook , Shuah Khan , "Rick P. Edgecombe" , Deepak Gupta , Ard Biesheuvel , Szabolcs Nagy , "H.J. Lu" , Paul Walmsley , Palmer Dabbelt , Albert Ou , Florian Weimer , Christian Brauner , linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, kvmarm@lists.linux.dev, linux-fsdevel@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org Subject: Re: [PATCH v8 33/38] kselftest/arm64: Add a GCS test program built with the system libc In-reply-to: <20240203-arm64-gcs-v8-33-c9fec77673ef@kernel.org> Date: Mon, 19 Feb 2024 23:15:57 -0300 Message-ID: <87sf1n7uea.fsf@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Rspam-User: X-Stat-Signature: ixuibfqsmpby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FYPYQWI2+rOtVQn1uURtsHJdy7ghlUYCUGSK7HAELNLhFfDHGv5omphQG5n3wwibsUindql+SmbtnvVBPP+I2nB+jhcEsHXnLNewRDC16kuzywI7WQN9/i42fO1gQSi3Sf35vmFE9VBdsP9BS2U4OCFUWiQTho6rPNA84WDrPX5Xqte4UH7vAB7KjFc3KzXFJPYuz8YNZQrzwK/l5zuDjoa7HdbB7Ao+zCmscWGJGizDJLxwJRt8zq6nDCfYf9jC4Ab+S7QK9xjwVUTHK5FSCvNbAQcb2NRzcw/zzyvPlpUhoN4fb1XxvQu3ZcsEUrNOSnpLEyi+62GMwaokb2+D+Zban0O5oiSWWE3I7A4JoNzUWj/A8O1v+Gz+DkF20QxgGUOu7vOzZKMuHCpVNf4IZ1El0iWK+7OmoOFlpu5he+E354rOoJtGvgGqjR1vZtsRqRamH25wXSMYSdpqCqf/wffI4CS7wLt5u3b4+v5uLHMEC+TcLC/6WJeNfgMrUkkXNYfEntxDNNBPjbRJ6A== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Mark Brown writes: > There are things like threads which nolibc struggles with which we want > to add coverage for, and the ABI allows us to test most of these even if > libc itself does not understand GCS so add a test application built > using the system libc. > > Signed-off-by: Mark Brown > --- > tools/testing/selftests/arm64/gcs/.gitignore | 1 + > tools/testing/selftests/arm64/gcs/Makefile | 4 +- > tools/testing/selftests/arm64/gcs/gcs-util.h | 10 + > tools/testing/selftests/arm64/gcs/libc-gcs.c | 736 +++++++++++++++++++++= ++++++ > 4 files changed, 750 insertions(+), 1 deletion(-) In v7, several tests weren't running in my FVT VM for some reason. This time they do: $ ./run_kselftest.sh -t arm64:libc-gcs TAP version 13 1..1 # timeout set to 45 # selftests: arm64: libc-gcs # TAP version 13 # 1..118 # # Starting 118 tests from 32 test cases. # # RUN global.can_call_function ... # # can_call_function: Test terminated unexpectedly by signal 11 # # FAIL global.can_call_function # not ok 1 global.can_call_function # # RUN global.gcs_enabled_thread ... # # OK global.gcs_enabled_thread # ok 2 global.gcs_enabled_thread =E2=8B=AE # # RUN invalid_mprotect.exec_bti.do_map_read ... # # Allocated stack from 0xffffb3aa9000-0xffffb3aaa000 # # OK invalid_mprotect.exec_bti.do_map_read # ok 118 invalid_mprotect.exec_bti.do_map_read # # FAILED: 117 / 118 tests passed. # # Totals: pass:117 fail:1 xfail:0 xpass:0 skip:0 error:0 not ok 1 selftests: arm64: libc-gcs # exit=3D1 The only issue as can be seen above is that the can_call_function test is failing. The child is getting a GCS Segmentation fault when returning from fork(). I tried debugging it with GDB, but I don't see what's wrong since the address in LR matches the first entry in GCSPR. Here is the debug session: (gdb) break libc-gcs.c:58 Breakpoint 1 at 0x3894: file libc-gcs.c, line 58. (gdb) set follow-fork-mode child (gdb) r Starting program: /var/tmp/selftests/arm64/libc-gcs [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/aarch64-linux-gnu/libthread_db.so.1". TAP version 13 1..118 # Starting 118 tests from 32 test cases. # RUN global.can_call_function ... [Attaching after Thread 0xfffff7ff7e80 (LWP 9164) fork to child process 916= 8] [New inferior 2 (process 9168)] [Detaching after fork from parent process 9164] [Inferior 1 (process 9164) detached] [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/aarch64-linux-gnu/libthread_db.so.1". Thread 2.1 "libc-gcs" received signal SIGSEGV, Segmentation fault Guarded Control Stack error. [Switching to Thread 0xfffff7ff7e80 (LWP 9168)] 0x0000fffff7ec6fc0 [GCS error] in __GI__Fork () at ../sysdeps/nptl/_Fork.c:= 50 warning: 50 ../sysdeps/nptl/_Fork.c: No such file or directory (gdb) bt #0 0x0000fffff7ec6fc0 [GCS error] in __GI__Fork () at ../sysdeps/nptl/_For= k.c:50 #1 0x0000fffff7ec6be0 in __libc_fork () at ./posix/fork.c:73 #2 0x0000aaaaaaaa49b8 in __run_test (f=3Df@entry=3D0xaaaaaaab98c8 <_fixtur= e_global>, variant=3Dvariant@entry=3D0xffffffffefb8, t=3Dt@entry=3D0xaaaaaaab81b0 = <_can_call_function_object>) at /home/thiago.bauermann/src/linux/tools/testing/selftests/kselftest_h= arness.h:1128 #3 0x0000aaaaaaaa2ac4 in test_harness_run (argv=3D0xfffffffff158, argc=3D1) at /home/thiago.bauermann/src/linux/tools/testing/selftests/kselftest_h= arness.h:1199 #4 main (argc=3D1, argv=3D0xfffffffff158) at libc-gcs.c:735 (gdb) p $gcspr $1 =3D (void *) 0xfffff7dfffe0 (gdb) p/x $lr $3 =3D 0xfffff7ec6be0 (gdb) p/x *(unsigned long *)$gcspr $5 =3D 0xfffff7ec6be0 (gdb) disassemble Dump of assembler code for function __GI__Fork: 0x0000fffff7ec6f70 <+0>: mrs x5, tpidr_el0 0x0000fffff7ec6f74 <+4>: mov x0, #0x11 // = #17 0x0000fffff7ec6f78 <+8>: sub x6, x5, #0x7c0 0x0000fffff7ec6f7c <+12>: sub x4, x5, #0x6f0 0x0000fffff7ec6f80 <+16>: movk x0, #0x120, lsl #16 0x0000fffff7ec6f84 <+20>: mov x1, #0x0 // = #0 0x0000fffff7ec6f88 <+24>: mov x2, #0x0 // = #0 0x0000fffff7ec6f8c <+28>: mov x3, #0x0 // = #0 0x0000fffff7ec6f90 <+32>: mov x8, #0xdc // = #220 0x0000fffff7ec6f94 <+36>: svc #0x0 0x0000fffff7ec6f98 <+40>: cmn x0, #0x1, lsl #12 0x0000fffff7ec6f9c <+44>: b.hi 0xfffff7ec6fc4 <__GI__Fork+84> // = b.pmore 0x0000fffff7ec6fa0 <+48>: mov w2, w0 0x0000fffff7ec6fa4 <+52>: cbnz w0, 0xfffff7ec6fbc <__GI__Fork+76> 0x0000fffff7ec6fa8 <+56>: sub x0, x5, #0x6e0 0x0000fffff7ec6fac <+60>: mov x1, #0x18 // = #24 0x0000fffff7ec6fb0 <+64>: mov x8, #0x63 // = #99 0x0000fffff7ec6fb4 <+68>: stp x0, x0, [x6, #216] 0x0000fffff7ec6fb8 <+72>: svc #0x0 0x0000fffff7ec6fbc <+76>: mov w0, w2 =3D> 0x0000fffff7ec6fc0 <+80>: ret 0x0000fffff7ec6fc4 <+84>: adrp x1, 0xfffff7faa000 0x0000fffff7ec6fc8 <+88>: ldr x1, [x1, #3528] 0x0000fffff7ec6fcc <+92>: neg w0, w0 0x0000fffff7ec6fd0 <+96>: mov w2, #0xffffffff // = #-1 0x0000fffff7ec6fd4 <+100>: str w0, [x5, x1] 0x0000fffff7ec6fd8 <+104>: mov w0, w2 0x0000fffff7ec6fdc <+108>: ret End of assembler dump. (gdb) p $w0 $8 =3D 0 (gdb) p $_siginfo.si_signo $12 =3D 11 (gdb) p $_siginfo.si_code $13 =3D 10 (gdb) p $_siginfo._sifields._sigfault.si_addr $14 =3D (void *) 0xfffff7ec6fc0 <__GI__Fork+80> --=20 Thiago