qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Berger <stefanb@linux.ibm.com>
To: "Peter Maydell" <peter.maydell@linaro.org>,
	"Cédric Le Goater" <clg@redhat.com>
Cc: qemu-arm@nongnu.org, qemu-devel@nongnu.org,
	Thomas Huth <thuth@redhat.com>,
	"Daniel P. Berrange" <berrange@redhat.com>
Subject: Re: [PULL 10/17] tests/functional: Convert most Aspeed machine tests
Date: Tue, 5 Nov 2024 11:35:46 -0500	[thread overview]
Message-ID: <91c2ac92-66b2-45c8-b4fe-e8f8587b0e9c@linux.ibm.com> (raw)
In-Reply-To: <CAFEAcA8A=kWLtTZ+nua-MpzqkaEjW5srOYZruZnE2tB6vmoMig@mail.gmail.com>



On 11/5/24 11:14 AM, Peter Maydell wrote:
> On Thu, 24 Oct 2024 at 07:39, Cédric Le Goater <clg@redhat.com> wrote:
>>
>> This is a simple conversion of the tests with some cleanups and
>> adjustments to match the new test framework. Replace the zephyr image
>> MD5 hashes with SHA256 hashes while at it.
> 
> (ccing Stefan Berger for possible insight into swtpm)
> 
> Hi; I find that this swtpm-using test fails for me on my
> local system due to an apparmor/swtpm problem...
> 
>> +    @skipUnless(*has_cmd('swtpm'))
>> +    def test_arm_ast2600_evb_buildroot_tpm(self):
>> +        self.set_machine('ast2600-evb')
>> +
>> +        image_path = self.ASSET_BR2_202302_AST2600_TPM_FLASH.fetch()
>> +
>> +        socket_dir = tempfile.TemporaryDirectory(prefix="qemu_")
>> +        socket = os.path.join(socket_dir.name, 'swtpm-socket')
>> +
>> +        subprocess.run(['swtpm', 'socket', '-d', '--tpm2',
>> +                        '--tpmstate', f'dir={self.vm.temp_dir}',
>> +                        '--ctrl', f'type=unixio,path={socket}'])
>> +
>> +        self.vm.add_args('-chardev', f'socket,id=chrtpm,path={socket}')
>> +        self.vm.add_args('-tpmdev', 'emulator,id=tpm0,chardev=chrtpm')
>> +        self.vm.add_args('-device',
>> +                         'tpm-tis-i2c,tpmdev=tpm0,bus=aspeed.i2c.bus.12,address=0x2e')
>> +        self.do_test_arm_aspeed_buildroot_start(image_path, '0xf00', 'Aspeed AST2600 EVB')
>> +
>> +        exec_command_and_wait_for_pattern(self,
>> +            'echo tpm_tis_i2c 0x2e > /sys/bus/i2c/devices/i2c-12/new_device',
>> +            'tpm_tis_i2c 12-002e: 2.0 TPM (device-id 0x1, rev-id 1)');
>> +        exec_command_and_wait_for_pattern(self,
>> +            'cat /sys/class/tpm/tpm0/pcr-sha256/0',
>> +            'B804724EA13F52A9072BA87FE8FDCC497DFC9DF9AA15B9088694639C431688E0');
>> +
>> +        self.do_test_arm_aspeed_buildroot_poweroff()
> 
> The test fails like this:
> 
> qemu-system-arm: tpm-emulator: TPM result for CMD_INIT: 0x9 operation failed
> 
> Adding extra logging to swtpm (--log file=/tmp/swtpm.log,level=20)
> reveals:
> 
> SWTPM_NVRAM_Lock_Lockfile: Could not open lockfile: Permission denied
> Error: Could not initialize libtpms.
> Error: Could not initialize the TPM
> 
> Checking the system logs, this is because apparmor has denied it:
> 
> Nov  5 16:01:14 e104462 kernel: [946406.489088] audit: type=1400
> audit(1730822474.384:446): apparmor="DENIED" operation="mknod"
> profile="swtpm"
> name="/mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/tests/functional/arm/test_arm_aspeed.AST2x00Machine.test_arm_ast2600_evb_buildroot_tpm/qemu-machine-hhuvwytc/.lock"
> pid=2820156 comm="swtpm" requested_mask="c" denied_mask="c" fsuid=1000
> ouid=1000
> 
> 
> 
> Q1: why is apparmor forbidding swtpm from doing something that
> it needs to do to work?

What distro and version is this?

The profile may be too strict and not reflecting all the paths needed 
for running the test cases. Ubuntu for example would have to update 
their profile in such a case.

> 
> Q2: is there a way to run swtpm such that it is not
> confined by apparmor, for purposes of running it in a test case?

Try either one:
- sudo aa-complain /usr/bin/swtpm
- sudo aa-disable /usr/bin/swtpm

> 
> Q3: if not, is there a way to at least detect that swtpm is
> broken on this system so we can skip the test case?

It's not swtpm that is broken but the AppArmor profile is too strict. 
Above command lines should work.

> 
> (I note that there is a thing in the apparmor config
> "owner @{HOME}/** rwk" which I think means you only run into
> this if you happen to be building/testing QEMU somewhere other
> than your own home directory -- but that's hardly an
> unreasonable configuration...)
> 
> thanks
> -- PMM



  reply	other threads:[~2024-11-05 17:03 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-24  6:34 [PULL 00/17] aspeed queue Cédric Le Goater
2024-10-24  6:34 ` [PULL 01/17] hw/gpio/aspeed: Fix coding style Cédric Le Goater
2024-10-24  6:34 ` [PULL 02/17] hw/gpio/aspeed: Support to set the different memory size Cédric Le Goater
2024-10-24  6:34 ` [PULL 03/17] hw/gpio/aspeed: Support different memory region ops Cédric Le Goater
2024-10-24  6:34 ` [PULL 04/17] hw/gpio/aspeed: Fix clear incorrect interrupt status for GPIO index mode Cédric Le Goater
2024-10-24  6:34 ` [PULL 05/17] hw/gpio/aspeed: Add AST2700 support Cédric Le Goater
2024-10-24  6:34 ` [PULL 06/17] aspeed/soc: Correct GPIO irq 130 for AST2700 Cédric Le Goater
2024-10-24  6:34 ` [PULL 07/17] aspeed/soc: Support GPIO " Cédric Le Goater
2024-10-24  6:34 ` [PULL 08/17] tests/qtest:ast2700-gpio-test: Add GPIO test case " Cédric Le Goater
2024-10-24  6:34 ` [PULL 09/17] hw/misc/aspeed_hace: Fix SG Accumulative hashing Cédric Le Goater
2024-10-24  6:35 ` [PULL 10/17] tests/functional: Convert most Aspeed machine tests Cédric Le Goater
2024-11-05 16:14   ` Peter Maydell
2024-11-05 16:35     ` Stefan Berger [this message]
2024-11-05 17:13       ` Peter Maydell
2024-11-05 18:02         ` Stefan Berger
2024-11-05 18:12           ` Peter Maydell
2024-11-05 18:35             ` Stefan Berger
2024-11-05 19:54               ` Peter Maydell
2024-11-05 20:12                 ` Stefan Berger
2024-11-05 21:34                   ` Peter Maydell
2024-11-05 21:50                     ` Stefan Berger
2024-11-06 15:21                       ` Stefan Berger
2024-10-24  6:35 ` [PULL 11/17] aspeed/smc: Fix write incorrect data into flash in user mode Cédric Le Goater
2024-10-24  6:35 ` [PULL 12/17] hw/block:m25p80: Fix coding style Cédric Le Goater
2024-10-24  6:35 ` [PULL 13/17] hw/block:m25p80: Support write status register 2 command (0x31) for w25q01jvq Cédric Le Goater
2024-10-24  6:35 ` [PULL 14/17] hw/block/m25p80: Add SFDP table for w25q80bl flash Cédric Le Goater
2024-10-24  6:35 ` [PULL 15/17] hw/arm/aspeed: Correct spi_model w25q256 for ast1030-a1 EVB Cédric Le Goater
2024-10-24  6:35 ` [PULL 16/17] hw/arm/aspeed: Correct fmc_model w25q80bl " Cédric Le Goater
2024-10-24  6:35 ` [PULL 17/17] test/qtest/aspeed_smc-test: Fix coding style Cédric Le Goater
2024-10-25 14:23 ` [PULL 00/17] aspeed queue Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=91c2ac92-66b2-45c8-b4fe-e8f8587b0e9c@linux.ibm.com \
    --to=stefanb@linux.ibm.com \
    --cc=berrange@redhat.com \
    --cc=clg@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=thuth@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).