lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAJ-ks9n4CpOEgHd9383JRWUJrUjSVshquHxUiiKSsQrC8KqX_A@mail.gmail.com>
Date: Sat, 2 Nov 2024 07:10:16 -0400
From: Tamir Duberstein <tamird@...il.com>
To: Thomas Weißschuh <thomas@...ch.de>
Cc: Alyssa Ross <hi@...ssa.is>, Brendan Higgins <brendan.higgins@...ux.dev>, 
	David Gow <davidgow@...gle.com>, Rae Moar <rmoar@...gle.com>, linux-kselftest@...r.kernel.org, 
	kunit-dev@...glegroups.com, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 2/2] kunit: enable hardware acceleration when available

On Fri, Nov 1, 2024 at 11:23 AM Thomas Weißschuh <thomas@...ch.de> wrote:
>
> On 2024-11-01 10:49:36-0400, Tamir Duberstein wrote:
> > On Fri, Nov 1, 2024, 09:52 Alyssa Ross <hi@...ssa.is> wrote:
> > >
> > > On Fri, Oct 25, 2024 at 05:03:54PM -0400, Tamir Duberstein wrote:
> > > > @@ -124,6 +125,29 @@ class LinuxSourceTreeOperationsQemu(LinuxSourceTreeOperations):
> > > >                               '-no-reboot',
> > > >                               '-nographic',
> > > >                               '-serial', self._serial] + self._extra_qemu_params
> > > > +             accelerators = {
> > > > +                     line.strip()
> > > > +                     for line in subprocess.check_output([qemu_binary, "-accel", "help"], text=True).splitlines()
> > > > +                     if line and line.islower()
> > > > +             }
> > > > +             if 'kvm' in accelerators:
> > > > +                     try:
> > > > +                             with open('/dev/kvm', 'rb+'):
> > > > +                                     qemu_command.extend(['-accel', 'kvm'])
> > > > +                     except OSError as e:
> > > > +                             print(e)
> > > > +             elif 'hvf' in accelerators:
> > > > +                     try:
> > > > +                             for line in subprocess.check_output(['sysctl', 'kern.hv_support'], text=True).splitlines():
> > > > +                                     if not line:
> > > > +                                             continue
> > > > +                                     key, value = line.split(':')
> > > > +                                     if key == 'kern.hv_support' and bool(value):
> > > > +                                             qemu_command.extend(['-accel', 'hvf'])
> > > > +                                             break
> > > > +                     except subprocess.CalledProcessError as e:
> > > > +                             print(e)
> > > > +
> > >
> > > QEMU supports falling back if one accelerator is not available, if you
> > > specify multiple like -accel kvm:tcg.  Couldn't you rely on that rather
> > > than re-implementing the availability checks here?
> >
> > Have you ever used that? Here's what I get when I try:
> >
> > tamird@...irs-MacBook-Pro linux % tools/testing/kunit/kunit.py run
> > --arch arm64 --make_options LLVM=1 --raw_output=all
> > [10:45:03] Configuring KUnit Kernel ...
> > [10:45:03] Building KUnit Kernel ...
> > Populating config with:
> > $ make ARCH=arm64 O=.kunit olddefconfig LLVM=1
> > Building with:
> > $ make all compile_commands.json ARCH=arm64 O=.kunit --jobs=12 LLVM=1
> > [10:45:07] Starting KUnit Kernel (1/1)...
> > 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 -accel kvm:tcg -machine virt -cpu max
> > qemu-system-aarch64: -accel kvm:tcg: invalid accelerator kvm:tcg
> >
> > The same thing happens with hvf:kvm:tcg or just hvf:tcg.
>
> That syntax is for -machine accel=hvf:kvm:tcg.
> But you can also specify -accel multiple times.
>
> > I also can't find this in the documentation.
>
> -accel name[,prop=value[,...]]
>       This  is used to enable an accelerator. [..]
>       If there is more than one accelerator specified,
>       the next one is used if the previous one fails to initialize.
>
> -machine [type=]name[,prop=value[,...]]
>       Supported machine properties are:
>
>       accel=accels1[:accels2[:...]]
>              [..]
>              If there is more than one accelerator specified,
>              the next one is used if the  previous one fails to initialize.
>
>
> Thomas

Nice, thank you. These details seem to appear only in the docs[0] and
not in the output of `--help`. I'll make that change in v2.

Link: https://www.qemu.org/docs/master/system/invocation.html [0]


Tamir

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ