mbox series

[RFC,0/9] Support disable/enable CPU features for AArch64

Message ID 20200813102657.2588720-1-liangpeng10@huawei.com (mailing list archive)
Headers show
Series Support disable/enable CPU features for AArch64 | expand

Message

Peng Liang Aug. 13, 2020, 10:26 a.m. UTC
QEMU does not support disable/enable CPU features in AArch64 for now.
This patch series add support for CPU features in AArch64.

Firstly, we change the isar struct in ARMCPU to an array for
convenience.  Secondly, we add support to configure CPU feautres in
AArch64 and make sure that the ID registers can be synchronized to KVM
so that guest can read the value we configure.  Thirdly, we add a
mechanism to solve the dependency relationship of some CPU features.
Last, we add a KVM_CAP_ARM_CPU_FEATURE to check whether KVM supports to
set CPU features in AArch64.

Also export CPU features to the result of qmp query-cpu-model-expansion
so that libvirt can get the supported CPU features.

Update the ID fields to ARMv8.6 and add some CPU features according to
the new ID fields.

With related KVM patch set[1], we can disable/enable CPU features in
AArch64.

[1] https://patchwork.kernel.org/cover/11711693/

Peng Liang (9):
  target/arm: convert isar regs to array
  target/arm: parse cpu feature related options
  target/arm: register CPU features for property
  target/arm: Allow ID registers to synchronize to KVM
  target/arm: introduce CPU feature dependency mechanism
  target/arm: introduce KVM_CAP_ARM_CPU_FEATURE
  target/arm: Add CPU features to query-cpu-model-expansion
  target/arm: Update ID fields
  target/arm: Add more CPU features

 hw/intc/armv7m_nvic.c     |  48 +--
 linux-headers/linux/kvm.h |   1 +
 target/arm/cpu.c          | 753 ++++++++++++++++++++++++++++++++------
 target/arm/cpu.h          | 245 +++++++------
 target/arm/cpu64.c        | 271 +++++++++-----
 target/arm/cpu_tcg.c      | 250 ++++++-------
 target/arm/helper.c       |  85 +++--
 target/arm/internals.h    |  15 +-
 target/arm/kvm.c          |  38 ++
 target/arm/kvm64.c        |  86 +++--
 target/arm/kvm_arm.h      |  10 +
 target/arm/monitor.c      |   2 +
 12 files changed, 1267 insertions(+), 537 deletions(-)

Comments

Andrew Jones Aug. 13, 2020, 2:10 p.m. UTC | #1
On Thu, Aug 13, 2020 at 06:26:48PM +0800, Peng Liang wrote:
> QEMU does not support disable/enable CPU features in AArch64 for now.

Yes, it does. We have a handful of CPU features implemented as CPU
properties and we have QMP support for probing those features and
testing whether they may be enabled or disabled.

> This patch series add support for CPU features in AArch64.

Actually, it just adds all possible features as properties without
considering if those features make sense to expose to users and
without considering all invalid configurations. That's not a great
approach.

We should try to tackle migration between non-identical hosts, but not by
dumping all the burden of determining a functional configuration on the
user. Instead, I think we need to audit what we're currently exposing to
guests from KVM. If there are CPU features that make sense for the user
to control, then we can do so using patterns for other CPU features that
are already under user control. If there are other ID register bits that
we should be masking/adjusting, then we can make those changes too. IOW,
let's take this one ID register at a time. Eventually, we'll come to the
real crux, which is MIDR. We need to provide a guest an MIDR that allows
it to migrate between hosts with different MIDRs. That'll likely open the
errata can of worms.

Thanks,
drew
no-reply@patchew.org Aug. 13, 2020, 4:30 p.m. UTC | #2
Patchew URL: https://patchew.org/QEMU/20200813102657.2588720-1-liangpeng10@huawei.com/



Hi,

This series seems to have some coding style problems. See output below for
more information:

Type: series
Message-id: 20200813102657.2588720-1-liangpeng10@huawei.com
Subject: [RFC 0/9] Support disable/enable CPU features for AArch64

=== TEST SCRIPT BEGIN ===
#!/bin/bash
git rev-parse base > /dev/null || exit 0
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram
./scripts/checkpatch.pl --mailback base..
=== TEST SCRIPT END ===

Switched to a new branch 'test'
155e490 target/arm: Add more CPU features
5564d59 target/arm: Update ID fields
2f12ecd target/arm: Add CPU features to query-cpu-model-expansion
0911682 target/arm: introduce KVM_CAP_ARM_CPU_FEATURE
9dddca9 target/arm: introduce CPU feature dependency mechanism
89874bb target/arm: Allow ID registers to synchronize to KVM
8286a4a target/arm: register CPU features for property
7101c88 target/arm: parse cpu feature related options
56111cc target/arm: convert isar regs to array

=== OUTPUT BEGIN ===
1/9 Checking commit 56111cc30af0 (target/arm: convert isar regs to array)
2/9 Checking commit 7101c885db04 (target/arm: parse cpu feature related options)
ERROR: consider using qemu_strtoupr in preference to strtoupr
#55: FILE: target/arm/cpu64.c:799:
+static char *strtoupr(char *str)

ERROR: consider using qemu_strtoupr in preference to strtoupr
#121: FILE: target/arm/cpu64.c:865:
+        tmp = strtoupr(tmp);

ERROR: consider using qemu_strtoupr in preference to strtoupr
#127: FILE: target/arm/cpu64.c:871:
+        const char *name = strtoupr(l->data); /* convert to upper string */

ERROR: consider using qemu_strtoupr in preference to strtoupr
#132: FILE: target/arm/cpu64.c:876:
+        const char *name = strtoupr(l->data);

total: 4 errors, 0 warnings, 119 lines checked

Patch 2/9 has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.

3/9 Checking commit 8286a4a789ed (target/arm: register CPU features for property)
4/9 Checking commit 89874bbdfd8e (target/arm: Allow ID registers to synchronize to KVM)
5/9 Checking commit 9dddca93c5b1 (target/arm: introduce CPU feature dependency mechanism)
6/9 Checking commit 091168210d47 (target/arm: introduce KVM_CAP_ARM_CPU_FEATURE)
7/9 Checking commit 2f12ecd63d30 (target/arm: Add CPU features to query-cpu-model-expansion)
ERROR: consider using qemu_strtolower in preference to strtolower
#32: FILE: target/arm/cpu.c:1520:
+static char *strtolower(char *src)

ERROR: consider using qemu_strtolower in preference to strtolower
#64: FILE: target/arm/cpu.c:1552:
+            tmp = strtolower(g_strdup(name));

total: 2 errors, 0 warnings, 67 lines checked

Patch 7/9 has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.

8/9 Checking commit 5564d59a9ee0 (target/arm: Update ID fields)
9/9 Checking commit 155e490920e3 (target/arm: Add more CPU features)
=== OUTPUT END ===

Test command exited with code: 1


The full log is available at
http://patchew.org/logs/20200813102657.2588720-1-liangpeng10@huawei.com/testing.checkpatch/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to patchew-devel@redhat.com
no-reply@patchew.org Aug. 13, 2020, 4:34 p.m. UTC | #3
Patchew URL: https://patchew.org/QEMU/20200813102657.2588720-1-liangpeng10@huawei.com/



Hi,

This series failed the docker-mingw@fedora build test. Please find the testing commands and
their output below. If you have Docker installed, you can probably reproduce it
locally.

=== TEST SCRIPT BEGIN ===
#! /bin/bash
export ARCH=x86_64
make docker-image-fedora V=1 NETWORK=1
time make docker-test-mingw@fedora J=14 NETWORK=1
=== TEST SCRIPT END ===

  CC      aarch64-softmmu/target/arm/translate-a64.o
  CC      aarch64-softmmu/target/arm/helper-a64.o
/tmp/qemu-test/src/target/arm/cpu.c: In function 'arm_cpu_set_bit_prop':
/tmp/qemu-test/src/target/arm/cpu.c:1586:10: error: implicit declaration of function 'kvm_arm_cpu_feature_supported'; did you mean 'kvm_arm_pmu_supported'? [-Werror=implicit-function-declaration]
 1586 |     if (!kvm_arm_cpu_feature_supported()) {
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |          kvm_arm_pmu_supported
/tmp/qemu-test/src/target/arm/cpu.c:1586:10: error: nested extern declaration of 'kvm_arm_cpu_feature_supported' [-Werror=nested-externs]
cc1: all warnings being treated as errors
make[1]: *** [/tmp/qemu-test/src/rules.mak:69: target/arm/cpu.o] Error 1
make[1]: *** Waiting for unfinished jobs....
make: *** [Makefile:527: aarch64-softmmu/all] Error 2
Traceback (most recent call last):
  File "./tests/docker/docker.py", line 709, in <module>
    sys.exit(main())
---
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['sudo', '-n', 'docker', 'run', '--label', 'com.qemu.instance.uuid=82498ab48b9d4e83a6e3d551852f7ce7', '-u', '1003', '--security-opt', 'seccomp=unconfined', '--rm', '-e', 'TARGET_LIST=', '-e', 'EXTRA_CONFIGURE_OPTS=', '-e', 'V=', '-e', 'J=14', '-e', 'DEBUG=', '-e', 'SHOW_ENV=', '-e', 'CCACHE_DIR=/var/tmp/ccache', '-v', '/home/patchew2/.cache/qemu-docker-ccache:/var/tmp/ccache:z', '-v', '/var/tmp/patchew-tester-tmp-05puycro/src/docker-src.2020-08-13-12.30.55.30563:/var/tmp/qemu:z,ro', 'qemu/fedora', '/var/tmp/qemu/run', 'test-mingw']' returned non-zero exit status 2.
filter=--filter=label=com.qemu.instance.uuid=82498ab48b9d4e83a6e3d551852f7ce7
make[1]: *** [docker-run] Error 1
make[1]: Leaving directory `/var/tmp/patchew-tester-tmp-05puycro/src'
make: *** [docker-run-test-mingw@fedora] Error 2

real    3m42.997s
user    0m9.285s


The full log is available at
http://patchew.org/logs/20200813102657.2588720-1-liangpeng10@huawei.com/testing.docker-mingw@fedora/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to patchew-devel@redhat.com
no-reply@patchew.org Aug. 13, 2020, 4:38 p.m. UTC | #4
Patchew URL: https://patchew.org/QEMU/20200813102657.2588720-1-liangpeng10@huawei.com/



Hi,

This series failed the docker-quick@centos7 build test. Please find the testing commands and
their output below. If you have Docker installed, you can probably reproduce it
locally.

=== TEST SCRIPT BEGIN ===
#!/bin/bash
make docker-image-centos7 V=1 NETWORK=1
time make docker-test-quick@centos7 SHOW_ENV=1 J=14 NETWORK=1
=== TEST SCRIPT END ===

  CC      aarch64-softmmu/target/arm/gdbstub64.o
  CC      aarch64-softmmu/target/arm/machine.o
/tmp/qemu-test/src/target/arm/cpu.c: In function 'arm_cpu_set_bit_prop':
/tmp/qemu-test/src/target/arm/cpu.c:1586:5: error: implicit declaration of function 'kvm_arm_cpu_feature_supported' [-Werror=implicit-function-declaration]
     if (!kvm_arm_cpu_feature_supported()) {
     ^
/tmp/qemu-test/src/target/arm/cpu.c:1586:5: error: nested extern declaration of 'kvm_arm_cpu_feature_supported' [-Werror=nested-externs]
cc1: all warnings being treated as errors
  CC      aarch64-softmmu/target/arm/arch_dump.o
  CC      aarch64-softmmu/target/arm/monitor.o
  CC      aarch64-softmmu/target/arm/arm-powerctl.o
make[1]: *** [target/arm/cpu.o] Error 1
make[1]: *** Waiting for unfinished jobs....
  CC      aarch64-softmmu/target/arm/kvm-stub.o
make: *** [aarch64-softmmu/all] Error 2
make: *** Waiting for unfinished jobs....
Traceback (most recent call last):
  File "./tests/docker/docker.py", line 709, in <module>
---
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['sudo', '-n', 'docker', 'run', '--label', 'com.qemu.instance.uuid=66c80c872bf54d5084de54fbccc4353c', '-u', '1001', '--security-opt', 'seccomp=unconfined', '--rm', '-e', 'TARGET_LIST=', '-e', 'EXTRA_CONFIGURE_OPTS=', '-e', 'V=', '-e', 'J=14', '-e', 'DEBUG=', '-e', 'SHOW_ENV=1', '-e', 'CCACHE_DIR=/var/tmp/ccache', '-v', '/home/patchew/.cache/qemu-docker-ccache:/var/tmp/ccache:z', '-v', '/var/tmp/patchew-tester-tmp-xzm_l9kf/src/docker-src.2020-08-13-12.35.23.5519:/var/tmp/qemu:z,ro', 'qemu/centos7', '/var/tmp/qemu/run', 'test-quick']' returned non-zero exit status 2.
filter=--filter=label=com.qemu.instance.uuid=66c80c872bf54d5084de54fbccc4353c
make[1]: *** [docker-run] Error 1
make[1]: Leaving directory `/var/tmp/patchew-tester-tmp-xzm_l9kf/src'
make: *** [docker-run-test-quick@centos7] Error 2

real    3m15.003s
user    0m8.959s


The full log is available at
http://patchew.org/logs/20200813102657.2588720-1-liangpeng10@huawei.com/testing.docker-quick@centos7/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to patchew-devel@redhat.com