Message ID | 20240214124131.990872-1-paul.heidekrueger@tum.de |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-65207-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:bc8a:b0:106:860b:bbdd with SMTP id dn10csp1182604dyb; Wed, 14 Feb 2024 04:42:09 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWfumEovEKSnrdIdsXEICB7nyPI8EHwEW5vIysEeqKKleFjZrmpelV6sXS1pfrWD11hgoakZu0EZJR38rCGQkuT7HPd8A== X-Google-Smtp-Source: AGHT+IE5H/q3PX0ZRe4lohQg9bVOhjEoZ5EEdJB62JCC0FZkSQ9vyX10OpFJM+SqJzxne5vblz3P X-Received: by 2002:a05:6359:4c11:b0:176:9bfd:d092 with SMTP id kj17-20020a0563594c1100b001769bfdd092mr2495520rwc.18.1707914529747; Wed, 14 Feb 2024 04:42:09 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707914529; cv=pass; d=google.com; s=arc-20160816; b=qtDHGuwRMZE9sfM9vPhwnJrE7ly+8m7AKRjip963X1y4gIXybvobW7LfEv+B4fzNVy WhJfKw5GYqlneKZggKNgMiYNrjMHMMtcnERz0hPMvF+B+Ft1bxTf9eGnGPvEa7kBRZnW Vn214lDu9ipJ7CjBtZkUF5fgc05hcVl362RXIqlPkwqNmNavZnM3dmb2IozOcxkYG1h0 qsV6y72cvEYoBpkZks1wiLyCi7fuwciNM8vcrMi/oID14JO34KPZ31Yq7i1ftDk7eRNM JAraLFOeFxyUHPNGC7T2tSggxW7dm2lkTH17pI/DL3fTCLXF/0/ss2ZwVObYlP9W0ujZ sZ4Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:to:from :dkim-signature; bh=cubOLyS8Uoy1YRtsHWtNJQ7olE/m7at3gcNjYKzhEzI=; fh=7JoLWr1ELfK+GZDG5Rq13KU2q8tGSI2vDtuh7izK+aI=; b=EV04vlXv5WEAca4OaV5OVa8uA0OL1D0mkYzs4doRJZ0krG4cdw7GV1U+gUS386HwB1 YvbK0WrVkMCz7229i7HftjB8xxtRJd7IgQLVyDIg9OLU+HSUxEgEfUsgv8g9hxDN230E cQDGdyc/vl3QQno3hd0J8oOxgdcmBWgq3lE8nJRDRl9Yr2avMMkz+gHHYVq/KWePdqkY gx8yxqnEVlpWTHsYlEktGtkVby2MxODA6lR+w3iwdO7SHUfb6EIH0Dp6kTjimXyAz8Ng 6HiZKDFIyvyatLeBabiuefhPux3Rf4nz/4MvWHq35w2sQ1xc8MnqG2tlIBNfkTgyQKTw CbvA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@tum.de header.s=tu-postout21 header.b=jCkm6hBA; arc=pass (i=1 spf=pass spfdomain=tum.de dkim=pass dkdomain=tum.de dmarc=pass fromdomain=tum.de); spf=pass (google.com: domain of linux-kernel+bounces-65207-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-65207-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=tum.de X-Forwarded-Encrypted: i=2; AJvYcCXnftQmqVDru0FMX2TMGMmGXUZ25b8dwFKC6GX0LxNZZx4AI19/Oi23Cte7BYNEmUH33/QPAnbes5oZQch3kOSgSq/CZg== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id w26-20020a63af1a000000b005dbd83521fasi3523666pge.883.2024.02.14.04.42.09 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 04:42:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-65207-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@tum.de header.s=tu-postout21 header.b=jCkm6hBA; arc=pass (i=1 spf=pass spfdomain=tum.de dkim=pass dkdomain=tum.de dmarc=pass fromdomain=tum.de); spf=pass (google.com: domain of linux-kernel+bounces-65207-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-65207-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=tum.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 7F4FD28FFCA for <ouuuleilei@gmail.com>; Wed, 14 Feb 2024 12:42:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4639352F79; Wed, 14 Feb 2024 12:42:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tum.de header.i=@tum.de header.b="jCkm6hBA" Received: from postout2.mail.lrz.de (postout2.mail.lrz.de [129.187.255.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EA0BD22626; Wed, 14 Feb 2024 12:41:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=129.187.255.138 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707914515; cv=none; b=EB4fT8dWtBcFCQq0rE2IpwulrcBlCAVZQib9JhRCVORlbycp6MsYFznlApvvVLSyAkiVRRxbmyUcu9kMiLT02gj7YH40koTRrKX7V3SFQzQGRIeprdxjJ31Sne08VOKMK5nVbOUhqAG/Mhyf03Jx/Vjt3CLRat7i/0gHuYUowf4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707914515; c=relaxed/simple; bh=+EUUACJwNj0bXAgQ+8GQThIgivD8jBsEM0i2kqiLRwY=; h=From:To:Subject:Date:Message-Id:MIME-Version:Content-Type; b=l+qDiNajiaMVY37ftQj5F5MrRJmIsK+IraIF36ruIKKRaBdCygNs9bb0bsHOuiEiTjz4nmTB39Y3BufMj66ItJmhE+ivrjjQ45cCjs9/R5LGvanm3wUbNAH4Q2no4qNSqGM460gc4yTlabW19OzEUoE//qWEy//h7sz/UtR0Etk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=tum.de; spf=pass smtp.mailfrom=tum.de; dkim=pass (2048-bit key) header.d=tum.de header.i=@tum.de header.b=jCkm6hBA; arc=none smtp.client-ip=129.187.255.138 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=tum.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tum.de Received: from lxmhs52.srv.lrz.de (localhost [127.0.0.1]) by postout2.mail.lrz.de (Postfix) with ESMTP id 4TZd9b6ncSzyQl; Wed, 14 Feb 2024 13:41:39 +0100 (CET) Authentication-Results: postout.lrz.de (amavisd-new); dkim=pass (2048-bit key) reason="pass (just generated, assumed good)" header.d=tum.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tum.de; h= content-transfer-encoding:content-type:content-type:mime-version :x-mailer:message-id:date:date:subject:subject:from:from :received:received; s=tu-postout21; t=1707914499; bh=+EUUACJwNj0 bXAgQ+8GQThIgivD8jBsEM0i2kqiLRwY=; b=jCkm6hBAGikTb7WTBbUgWqzy6+n MsU6lh8LMf1BCN9aH1xVbcH/sFPSBiQop0SsmjtM5kaa2KtqVuTdQzaH7+UKcBti UYgXAEs4yn6t7PtVqE2DyL3Hgeb95O9WASOIqeH2sCluXDjHGV8cZcFS0OtaYEfR 1QuI+8UfinrKRCbac2fhqtE98tV5zC7cfRETITUmcBNzMAybCcT5jpH+I7Ayh1y9 igQsXtpwQh8aZtD2t8f+HkIyROc7yn9VCgnG+2pxhSxBJ76t4Kj15khxwPxVcS5q fzBll2eylnTAsjnBgn/r5Hy0qk1jkQARZ0Ngh0PqocArdBiY0+/v+KRAVjA== X-Virus-Scanned: by amavisd-new at lrz.de in lxmhs52.srv.lrz.de X-Spam-Flag: NO X-Spam-Score: -2.885 X-Spam-Level: Received: from postout2.mail.lrz.de ([127.0.0.1]) by lxmhs52.srv.lrz.de (lxmhs52.srv.lrz.de [127.0.0.1]) (amavisd-new, port 20024) with LMTP id RoFk6-aGmlmz; Wed, 14 Feb 2024 13:41:39 +0100 (CET) Received: from sienna.fritz.box (ppp-93-104-85-184.dynamic.mnet-online.de [93.104.85.184]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by postout2.mail.lrz.de (Postfix) with ESMTPSA id 4TZd9Z5vmmzyRs; Wed, 14 Feb 2024 13:41:38 +0100 (CET) From: =?utf-8?q?Paul_Heidekr=C3=BCger?= <paul.heidekrueger@tum.de> To: Brendan Higgins <brendan.higgins@linux.dev>, David Gow <davidgow@google.com>, Mark Brown <broonie@kernel.org>, Shuah Khan <skhan@linuxfoundation.org>, =?utf-8?q?Paul_Heidekr=C3=BCger?= <paul.heidekrueger@tum.de>, linux-kselftest@vger.kernel.org (open list:KERNEL UNIT TESTING FRAMEWORK (KUnit)), kunit-dev@googlegroups.com (open list:KERNEL UNIT TESTING FRAMEWORK (KUnit)), linux-kernel@vger.kernel.org (open list) Subject: [PATCH RFC] kunit: tool: add 'mte=on' qemu arg on arm64 Date: Wed, 14 Feb 2024 12:41:30 +0000 Message-Id: <20240214124131.990872-1-paul.heidekrueger@tum.de> X-Mailer: git-send-email 2.40.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790878185518997618 X-GMAIL-MSGID: 1790878185518997618 |
Series |
[RFC] kunit: tool: add 'mte=on' qemu arg on arm64
|
|
Commit Message
Paul Heidekrüger
Feb. 14, 2024, 12:41 p.m. UTC
Hi!
I was running some KASan tests with kunit.py recently and noticed that
when KASan is run in hw tags mode, we manually have to add the required
`mte=on` option to kunit_tool's qemu invocation, as the tests will
otherwise crash.
To make life easier, I was looking into ways for kunit.py to recognise
when MTE support was required and set the option automatically.
All solutions I could come up with for having kunit_tool conditionally
pass `mte=on` to qemu, either entailed duplicate code or required
parsing of kernel's config file again. I was working under the
assumption that only after configuring the kernel we would know whether
the 'mte=on' option was necessary, as CONFIG_ARM64_MTE is not visible
before.
Only afterwads did I realise that the qemu arm64 config that kunit_tool
falls back on, uses the `virt` machine, which supports MTE in any case.
So, could it be as easy as just adding the `mte=on` option to
kunit_tool's arm64 config? Would this be a welcome addition?
What do you think?
Many thanks,
Paul
Signed-off-by: Paul Heidekrüger <paul.heidekrueger@tum.de>
---
tools/testing/kunit/qemu_configs/arm64.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
On Wed, 14 Feb 2024 at 20:41, Paul Heidekrüger <paul.heidekrueger@tum.de> wrote: > > Hi! > > I was running some KASan tests with kunit.py recently and noticed that > when KASan is run in hw tags mode, we manually have to add the required > `mte=on` option to kunit_tool's qemu invocation, as the tests will > otherwise crash. > > To make life easier, I was looking into ways for kunit.py to recognise > when MTE support was required and set the option automatically. > > All solutions I could come up with for having kunit_tool conditionally > pass `mte=on` to qemu, either entailed duplicate code or required > parsing of kernel's config file again. I was working under the > assumption that only after configuring the kernel we would know whether > the 'mte=on' option was necessary, as CONFIG_ARM64_MTE is not visible > before. > > Only afterwads did I realise that the qemu arm64 config that kunit_tool > falls back on, uses the `virt` machine, which supports MTE in any case. > So, could it be as easy as just adding the `mte=on` option to > kunit_tool's arm64 config? Would this be a welcome addition? > > What do you think? > > Many thanks, > Paul > > Signed-off-by: Paul Heidekrüger <paul.heidekrueger@tum.de> > --- I think this is fine. I'd be a little bit concerned if this were only supported in newer qemu versions, but it seems to go back to 6.2, so should be okay. I think it's better to just enable it unconditionally by default rather than trying to parse the config. The KASAN tests seemed to work fine with HW tags in my testing here. I do wonder if there's a way to make the tests skip themselves if MTE isn't available: is there a way of doing a runtime check for this? Regardless, this is: Reviewed-by: David Gow <davidgow@google.com> -- David > tools/testing/kunit/qemu_configs/arm64.py | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/tools/testing/kunit/qemu_configs/arm64.py b/tools/testing/kunit/qemu_configs/arm64.py > index d3ff27024755..a525f7e1093b 100644 > --- a/tools/testing/kunit/qemu_configs/arm64.py > +++ b/tools/testing/kunit/qemu_configs/arm64.py > @@ -9,4 +9,4 @@ CONFIG_SERIAL_AMBA_PL011_CONSOLE=y''', > qemu_arch='aarch64', > kernel_path='arch/arm64/boot/Image.gz', > kernel_command_line='console=ttyAMA0', > - extra_qemu_params=['-machine', 'virt', '-cpu', 'max,pauth-impdef=on']) > + extra_qemu_params=['-machine', 'virt,mte=on', '-cpu', 'max,pauth-impdef=on']) > -- > 2.40.1 >
On 20.02.2024 08:46, David Gow wrote: > On Wed, 14 Feb 2024 at 20:41, Paul Heidekrüger <paul.heidekrueger@tum.de> wrote: > > > > Hi! > > > > I was running some KASan tests with kunit.py recently and noticed that > > when KASan is run in hw tags mode, we manually have to add the required > > `mte=on` option to kunit_tool's qemu invocation, as the tests will > > otherwise crash. > > > > To make life easier, I was looking into ways for kunit.py to recognise > > when MTE support was required and set the option automatically. > > > > All solutions I could come up with for having kunit_tool conditionally > > pass `mte=on` to qemu, either entailed duplicate code or required > > parsing of kernel's config file again. I was working under the > > assumption that only after configuring the kernel we would know whether > > the 'mte=on' option was necessary, as CONFIG_ARM64_MTE is not visible > > before. > > > > Only afterwads did I realise that the qemu arm64 config that kunit_tool > > falls back on, uses the `virt` machine, which supports MTE in any case. > > So, could it be as easy as just adding the `mte=on` option to > > kunit_tool's arm64 config? Would this be a welcome addition? > > > > What do you think? > > > > Many thanks, > > Paul > > > > Signed-off-by: Paul Heidekrüger <paul.heidekrueger@tum.de> > > --- > > I think this is fine. I'd be a little bit concerned if this were only > supported in newer qemu versions, but it seems to go back to 6.2, so > should be okay. I think it's better to just enable it unconditionally > by default rather than trying to parse the config. > > The KASAN tests seemed to work fine with HW tags in my testing here. I > do wonder if there's a way to make the tests skip themselves if MTE > isn't available: is there a way of doing a runtime check for this? Huh, interesting. Even though "mte=on" isn't set on your side? I get the following output without the MTE patch. ➜ ./tools/testing/kunit/kunit.py run --kunitconfig=mm/kasan/.kunitconfig --arch=arm64 [14:08:11] Configuring KUnit Kernel ... [14:08:11] Building KUnit Kernel ... Populating config with: $ make ARCH=arm64 O=.kunit olddefconfig Building with: $ make ARCH=arm64 O=.kunit --jobs=8 [14:08:23] Starting KUnit Kernel (1/1)... [14:08:23] ============================================================ Running tests with: $ qemu-system-aarch64 -nodefaults -m 1024 -kernel .kunit/arch/arm64/boot/Image.gz -append 'kunit.enable=1 console=ttyAMA0 kunit_shutdown=reboot' -no-reboot -nographic -serial stdio -machine virt -cpu max,pauth-impdef=on [14:08:23] kasan: test: Can't run KASAN tests with KASAN disabled [14:08:23] # kasan: # failed to initialize (-1) [14:08:23] [FAILED] kasan [14:08:23] ============================================================ [14:08:23] Testing complete. Ran 1 tests: failed: 1 [14:08:24] Elapsed time: 12.374s total, 0.001s configuring, 11.937s building, 0.382s running Where the mentioned .kunitconfig has the following options set for KASan. CONFIG_KUNIT=y CONFIG_KUNIT_ALL_TESTS=n CONFIG_FTRACE=y CONFIG_STACK_TRACER=y CONFIG_KASAN=y CONFIG_KASAN_HW_TAGS=y CONFIG_KASAN_KUNIT_TEST=y With the MTE patch from my previous email, everything works just fine. Based on that, do you have a guess why it's working for you and why it isn't for me? > Regardless, this is: > Reviewed-by: David Gow <davidgow@google.com> Thanks! I'll be sending a non-RFC patch shortly. Many thanks, Paul
diff --git a/tools/testing/kunit/qemu_configs/arm64.py b/tools/testing/kunit/qemu_configs/arm64.py index d3ff27024755..a525f7e1093b 100644 --- a/tools/testing/kunit/qemu_configs/arm64.py +++ b/tools/testing/kunit/qemu_configs/arm64.py @@ -9,4 +9,4 @@ CONFIG_SERIAL_AMBA_PL011_CONSOLE=y''', qemu_arch='aarch64', kernel_path='arch/arm64/boot/Image.gz', kernel_command_line='console=ttyAMA0', - extra_qemu_params=['-machine', 'virt', '-cpu', 'max,pauth-impdef=on']) + extra_qemu_params=['-machine', 'virt,mte=on', '-cpu', 'max,pauth-impdef=on'])