mirror of
https://github.com/utmapp/qemu.git
synced 2026-12-04 16:12:57 -10:00
Compare commits
166
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f818886828 | ||
|
|
9748378628 | ||
|
|
1fc3358fee | ||
|
|
2b0fd418aa | ||
|
|
d66b46f0be | ||
|
|
5786281b5f | ||
|
|
f9a11d22b1 | ||
|
|
e97555efb5 | ||
|
|
3f949cf30c | ||
|
|
80c0e3099f | ||
|
|
c874e68e5a | ||
|
|
531da34587 | ||
|
|
34b035535e | ||
|
|
bb5c41eb13 | ||
|
|
b3cf3579f5 | ||
|
|
96e76ff0a1 | ||
|
|
3ef0f0db05 | ||
|
|
f129a2b8db | ||
|
|
6e9f737fcc | ||
|
|
51a16884c3 | ||
|
|
6626058f22 | ||
|
|
0fbf694119 | ||
|
|
12d182898a | ||
|
|
25dfefc810 | ||
|
|
397bb125e1 | ||
|
|
355b0824c6 | ||
|
|
84641e7ceb | ||
|
|
1716a3f189 | ||
|
|
aac64f9286 | ||
|
|
85af432691 | ||
|
|
a0167d013f | ||
|
|
3acd8e70ba | ||
|
|
e0af80866a | ||
|
|
b3ebe68e23 | ||
|
|
9e45375602 | ||
|
|
bdf261c858 | ||
|
|
ad2fe378fe | ||
|
|
3f620296d8 | ||
|
|
f2098f2c30 | ||
|
|
7dfd20c7e8 | ||
|
|
41eb76f5bf | ||
|
|
99ac5e48e4 | ||
|
|
67876f074e | ||
|
|
781a23afc7 | ||
|
|
1f24abea06 | ||
|
|
de8f1b03d0 | ||
|
|
66553a8213 | ||
|
|
4214699f96 | ||
|
|
401a81844b | ||
|
|
129127242d | ||
|
|
c146fe8095 | ||
|
|
e6441f8683 | ||
|
|
7135bae71b | ||
|
|
c9eb230657 | ||
|
|
ee9a9b425f | ||
|
|
5286a192c8 | ||
|
|
f854a87eeb | ||
|
|
1699eb16a7 | ||
|
|
d1792ff228 | ||
|
|
cd85cb5abe | ||
|
|
c94e174af8 | ||
|
|
8f1617b581 | ||
|
|
fc43b65e06 | ||
|
|
6409730ff9 | ||
|
|
cc24c9b7cb | ||
|
|
0d24c5332f | ||
|
|
44cfb32e24 | ||
|
|
e73864e11d | ||
|
|
2b73a7937d | ||
|
|
753fffe1ea | ||
|
|
e19e3cb9b5 | ||
|
|
26324b7d94 | ||
|
|
929b3859bd | ||
|
|
fdd3d1d3a0 | ||
|
|
345ec3279b | ||
|
|
e8f8220618 | ||
|
|
f275f433af | ||
|
|
f384e2c7eb | ||
|
|
dc386f9eb0 | ||
|
|
1adb9ff17d | ||
|
|
ce01739e6d | ||
|
|
f357b925b3 | ||
|
|
edba23a4d4 | ||
|
|
3428101c02 | ||
|
|
1e8db1949d | ||
|
|
e91d59cbea | ||
|
|
eace1c8c9f | ||
|
|
c800dbb61e | ||
|
|
b3a305701e | ||
|
|
21954ae12a | ||
|
|
61f5befa07 | ||
|
|
45c171c238 | ||
|
|
1b10cab21a | ||
|
|
c61c853e1f | ||
|
|
8681835e66 | ||
|
|
adaef950b5 | ||
|
|
a1cbf10708 | ||
|
|
d0c0d66796 | ||
|
|
920d2875a0 | ||
|
|
5ba17fba6e | ||
|
|
51f8c2e5b8 | ||
|
|
3184f37bbe | ||
|
|
110dbe7e89 | ||
|
|
2565eea22b | ||
|
|
8c2f5eff66 | ||
|
|
db430377c0 | ||
|
|
b2708c4684 | ||
|
|
9ea8f7a804 | ||
|
|
6a1e678f5b | ||
|
|
902616b2f0 | ||
|
|
bc73e87997 | ||
|
|
7292f1fc18 | ||
|
|
2ee6330b9e | ||
|
|
a0db5bfa90 | ||
|
|
998320a3da | ||
|
|
8137225fde | ||
|
|
3f09807e7f | ||
|
|
17d38dc6d9 | ||
|
|
66c71d88ed | ||
|
|
30adfa9b1d | ||
|
|
3bf12f1f40 | ||
|
|
4c82b50085 | ||
|
|
f3b4506f14 | ||
|
|
056bdd9a51 | ||
|
|
0bc7389a8e | ||
|
|
9517f7e873 | ||
|
|
30c2f78449 | ||
|
|
ea9f45cec5 | ||
|
|
82e6e2bdff | ||
|
|
ffb51175ba | ||
|
|
a13fec6c17 | ||
|
|
cf664b3a04 | ||
|
|
5897229105 | ||
|
|
d35954d3c9 | ||
|
|
64dcc3969b | ||
|
|
06962e1aaa | ||
|
|
ec151f4659 | ||
|
|
9d9ca24b72 | ||
|
|
fe1b754eab | ||
|
|
6d6e43ebce | ||
|
|
f479e7eacd | ||
|
|
dbbbd13bf6 | ||
|
|
dc32fd2d89 | ||
|
|
3354c800ac | ||
|
|
365294d55a | ||
|
|
a6bff5ccc8 | ||
|
|
c803fc9d7d | ||
|
|
653cc15628 | ||
|
|
2e77c788d8 | ||
|
|
1534c4fe04 | ||
|
|
3a513c9db4 | ||
|
|
e27df17c9c | ||
|
|
aa7ebf9a77 | ||
|
|
be54898fd5 | ||
|
|
7a64de81ce | ||
|
|
71f21b796f | ||
|
|
4e70afa94d | ||
|
|
36195a781c | ||
|
|
2541dde936 | ||
|
|
ecc067a3ba | ||
|
|
819b2c2984 | ||
|
|
8ed0f7cb4d | ||
|
|
d1bf1e28b6 | ||
|
|
47cd50d3d2 | ||
|
|
324cef19f8 | ||
|
|
e252078b6e |
No files matched your search
+25
-20
@@ -109,8 +109,8 @@ crash-test-debian:
|
||||
IMAGE: debian-amd64
|
||||
script:
|
||||
- cd build
|
||||
- make NINJA=":" check-venv
|
||||
- tests/venv/bin/python3 scripts/device-crash-test -q --tcg-only ./qemu-system-i386
|
||||
- make check-venv
|
||||
- tests/venv/bin/python3 scripts/device-crash-test -q ./qemu-system-i386
|
||||
|
||||
build-system-fedora:
|
||||
extends: .native_build_job_template
|
||||
@@ -155,16 +155,16 @@ crash-test-fedora:
|
||||
IMAGE: fedora
|
||||
script:
|
||||
- cd build
|
||||
- make NINJA=":" check-venv
|
||||
- make check-venv
|
||||
- tests/venv/bin/python3 scripts/device-crash-test -q ./qemu-system-ppc
|
||||
- tests/venv/bin/python3 scripts/device-crash-test -q ./qemu-system-riscv32
|
||||
|
||||
build-system-centos:
|
||||
extends: .native_build_job_template
|
||||
needs:
|
||||
job: amd64-centos9-container
|
||||
job: amd64-centos8-container
|
||||
variables:
|
||||
IMAGE: centos9
|
||||
IMAGE: centos8
|
||||
CONFIGURE_ARGS: --disable-nettle --enable-gcrypt --enable-fdt=system
|
||||
--enable-modules --enable-trace-backends=dtrace --enable-docs
|
||||
--enable-vfio-user-server
|
||||
@@ -182,7 +182,7 @@ check-system-centos:
|
||||
- job: build-system-centos
|
||||
artifacts: true
|
||||
variables:
|
||||
IMAGE: centos9
|
||||
IMAGE: centos8
|
||||
MAKE_CHECK_ARGS: check
|
||||
|
||||
avocado-system-centos:
|
||||
@@ -191,7 +191,7 @@ avocado-system-centos:
|
||||
- job: build-system-centos
|
||||
artifacts: true
|
||||
variables:
|
||||
IMAGE: centos9
|
||||
IMAGE: centos8
|
||||
MAKE_CHECK_ARGS: check-avocado
|
||||
|
||||
build-system-opensuse:
|
||||
@@ -237,9 +237,9 @@ avocado-system-opensuse:
|
||||
build-tcg-disabled:
|
||||
extends: .native_build_job_template
|
||||
needs:
|
||||
job: amd64-centos9-container
|
||||
job: amd64-centos8-container
|
||||
variables:
|
||||
IMAGE: centos9
|
||||
IMAGE: centos8
|
||||
script:
|
||||
- mkdir build
|
||||
- cd build
|
||||
@@ -469,6 +469,7 @@ tsan-build:
|
||||
CONFIGURE_ARGS: --enable-tsan --cc=clang-10 --cxx=clang++-10
|
||||
--enable-trace-backends=ust --enable-fdt=system --disable-slirp
|
||||
TARGETS: x86_64-softmmu ppc64-softmmu riscv64-softmmu x86_64-linux-user
|
||||
MAKE_CHECK_ARGS: bench V=1
|
||||
|
||||
# gprof/gcov are GCC features
|
||||
build-gprof-gcov:
|
||||
@@ -559,22 +560,29 @@ build-coroutine-sigaltstack:
|
||||
MAKE_CHECK_ARGS: check-unit
|
||||
|
||||
# Check our reduced build configurations
|
||||
build-without-defaults:
|
||||
build-without-default-devices:
|
||||
extends: .native_build_job_template
|
||||
needs:
|
||||
job: amd64-centos9-container
|
||||
job: amd64-centos8-container
|
||||
variables:
|
||||
IMAGE: centos9
|
||||
IMAGE: centos8
|
||||
CONFIGURE_ARGS: --without-default-devices --disable-user
|
||||
|
||||
build-without-default-features:
|
||||
extends: .native_build_job_template
|
||||
needs:
|
||||
job: amd64-fedora-container
|
||||
variables:
|
||||
IMAGE: fedora
|
||||
CONFIGURE_ARGS:
|
||||
--without-default-devices
|
||||
--without-default-features
|
||||
--disable-fdt
|
||||
--disable-capstone
|
||||
--disable-pie
|
||||
--disable-qom-cast-debug
|
||||
--disable-strip
|
||||
TARGETS: avr-softmmu mips64-softmmu s390x-softmmu sh4-softmmu
|
||||
TARGETS: avr-softmmu i386-softmmu mips64-softmmu s390x-softmmu sh4-softmmu
|
||||
sparc64-softmmu hexagon-linux-user i386-linux-user s390x-linux-user
|
||||
MAKE_CHECK_ARGS: check-unit check-qtest-avr check-qtest-mips64
|
||||
MAKE_CHECK_ARGS: check-unit check-qtest SPEED=slow
|
||||
|
||||
build-libvhost-user:
|
||||
extends: .base_job_template
|
||||
@@ -629,10 +637,7 @@ pages:
|
||||
- mkdir -p public
|
||||
# HTML-ised source tree
|
||||
- make gtags
|
||||
# We unset variables to work around a bug in some htags versions
|
||||
# which causes it to fail when the environment is large
|
||||
- CI_COMMIT_MESSAGE= CI_COMMIT_TAG_MESSAGE= htags
|
||||
-anT --tree-view=filetree -m qemu_init
|
||||
- htags -anT --tree-view=filetree -m qemu_init
|
||||
-t "Welcome to the QEMU sourcecode"
|
||||
- mv HTML public/src
|
||||
# Project documentation
|
||||
|
||||
@@ -20,12 +20,12 @@ reponame = os.path.basename(cwd)
|
||||
repourl = "https://gitlab.com/%s/%s.git" % (namespace, reponame)
|
||||
|
||||
subprocess.check_call(["git", "remote", "add", "check-dco", repourl])
|
||||
subprocess.check_call(["git", "fetch", "check-dco", "stable-7.2"],
|
||||
subprocess.check_call(["git", "fetch", "check-dco", "master"],
|
||||
stdout=subprocess.DEVNULL,
|
||||
stderr=subprocess.DEVNULL)
|
||||
|
||||
ancestor = subprocess.check_output(["git", "merge-base",
|
||||
"check-dco/stable-7.2", "HEAD"],
|
||||
"check-dco/master", "HEAD"],
|
||||
universal_newlines=True)
|
||||
|
||||
ancestor = ancestor.strip()
|
||||
@@ -85,7 +85,7 @@ This can be achieved by passing the "-s" flag to the "git commit" command.
|
||||
|
||||
To bulk update all commits on current branch "git rebase" can be used:
|
||||
|
||||
git rebase -i stable-7.2 -x 'git commit --amend --no-edit -s'
|
||||
git rebase -i master -x 'git commit --amend --no-edit -s'
|
||||
|
||||
""")
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
.cirrus_build_job:
|
||||
extends: .base_job_template
|
||||
stage: build
|
||||
image: registry.gitlab.com/libvirt/libvirt-ci/cirrus-run:latest
|
||||
image: registry.gitlab.com/libvirt/libvirt-ci/cirrus-run:master
|
||||
needs: []
|
||||
timeout: 80m
|
||||
allow_failure: true
|
||||
@@ -63,12 +63,11 @@ x64-freebsd-13-build:
|
||||
NAME: freebsd-13
|
||||
CIRRUS_VM_INSTANCE_TYPE: freebsd_instance
|
||||
CIRRUS_VM_IMAGE_SELECTOR: image_family
|
||||
CIRRUS_VM_IMAGE_NAME: freebsd-13-3
|
||||
CIRRUS_VM_IMAGE_NAME: freebsd-13-1
|
||||
CIRRUS_VM_CPUS: 8
|
||||
CIRRUS_VM_RAM: 8G
|
||||
UPDATE_COMMAND: pkg update
|
||||
INSTALL_COMMAND: pkg install -y
|
||||
CONFIGURE_ARGS: --target-list-exclude=arm-softmmu,i386-softmmu,microblaze-softmmu,mips64el-softmmu,mipsel-softmmu,mips-softmmu,ppc-softmmu,sh4eb-softmmu,xtensa-softmmu
|
||||
TEST_TARGETS: check
|
||||
|
||||
aarch64-macos-12-base-build:
|
||||
@@ -84,7 +83,6 @@ aarch64-macos-12-base-build:
|
||||
INSTALL_COMMAND: brew install
|
||||
PATH_EXTRA: /opt/homebrew/ccache/libexec:/opt/homebrew/gettext/bin
|
||||
PKG_CONFIG_PATH: /opt/homebrew/curl/lib/pkgconfig:/opt/homebrew/ncurses/lib/pkgconfig:/opt/homebrew/readline/lib/pkgconfig
|
||||
CONFIGURE_ARGS: --target-list-exclude=arm-softmmu,i386-softmmu,microblazeel-softmmu,mips64-softmmu,mipsel-softmmu,mips-softmmu,ppc-softmmu,sh4-softmmu,xtensaeb-softmmu
|
||||
TEST_TARGETS: check-unit check-block check-qapi-schema check-softfloat check-qtest-x86_64
|
||||
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ build_task:
|
||||
install_script:
|
||||
- @UPDATE_COMMAND@
|
||||
- @INSTALL_COMMAND@ @PKGS@
|
||||
- if test -n "@PYPI_PKGS@" ; then PYLIB=$(@PYTHON@ -c 'import sysconfig; print(sysconfig.get_path("stdlib"))'); rm -f $PYLIB/EXTERNALLY-MANAGED; @PIP3@ install @PYPI_PKGS@ ; fi
|
||||
- if test -n "@PYPI_PKGS@" ; then @PIP3@ install @PYPI_PKGS@ ; fi
|
||||
clone_script:
|
||||
- git clone --depth 100 "$CI_REPOSITORY_URL" .
|
||||
- git fetch origin "$CI_COMMIT_REF_NAME"
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
include:
|
||||
- local: '/.gitlab-ci.d/container-template.yml'
|
||||
|
||||
amd64-centos9-container:
|
||||
amd64-centos8-container:
|
||||
extends: .container_job_template
|
||||
variables:
|
||||
NAME: centos9
|
||||
NAME: centos8
|
||||
|
||||
amd64-fedora-container:
|
||||
extends: .container_job_template
|
||||
|
||||
@@ -115,7 +115,6 @@ riscv64-debian-cross-container:
|
||||
allow_failure: true
|
||||
variables:
|
||||
NAME: debian-riscv64-cross
|
||||
QEMU_JOB_OPTIONAL: 1
|
||||
|
||||
# we can however build TCG tests using a non-sid base
|
||||
riscv64-debian-test-cross-container:
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
# All jobs needing docker-edk2 must use the same rules it uses.
|
||||
.edk2_job_rules:
|
||||
rules:
|
||||
# Forks don't get pipelines unless QEMU_CI=1 or QEMU_CI=2 is set
|
||||
- if: '$QEMU_CI != "1" && $QEMU_CI != "2" && $CI_PROJECT_NAMESPACE != "qemu-project"'
|
||||
when: never
|
||||
|
||||
# In forks, if QEMU_CI=1 is set, then create manual job
|
||||
# if any of the files affecting the build are touched
|
||||
- if: '$QEMU_CI == "1" && $CI_PROJECT_NAMESPACE != "qemu-project"'
|
||||
changes:
|
||||
- .gitlab-ci.d/edk2.yml
|
||||
- .gitlab-ci.d/edk2/Dockerfile
|
||||
- roms/edk2/*
|
||||
when: manual
|
||||
|
||||
# In forks, if QEMU_CI=1 is set, then create manual job
|
||||
# if the branch/tag starts with 'edk2'
|
||||
- if: '$QEMU_CI == "1" && $CI_PROJECT_NAMESPACE != "qemu-project" && $CI_COMMIT_REF_NAME =~ /^edk2/'
|
||||
when: manual
|
||||
|
||||
# In forks, if QEMU_CI=1 is set, then create manual job
|
||||
# if last commit msg contains 'EDK2' (case insensitive)
|
||||
- if: '$QEMU_CI == "1" && $CI_PROJECT_NAMESPACE != "qemu-project" && $CI_COMMIT_MESSAGE =~ /edk2/i'
|
||||
when: manual
|
||||
|
||||
# Run if any files affecting the build output are touched
|
||||
- changes:
|
||||
- .gitlab-ci.d/edk2.yml
|
||||
- .gitlab-ci.d/edk2/Dockerfile
|
||||
- roms/edk2/*
|
||||
when: on_success
|
||||
|
||||
# Run if the branch/tag starts with 'edk2'
|
||||
- if: '$CI_COMMIT_REF_NAME =~ /^edk2/'
|
||||
when: on_success
|
||||
|
||||
# Run if last commit msg contains 'EDK2' (case insensitive)
|
||||
- if: '$CI_COMMIT_MESSAGE =~ /edk2/i'
|
||||
when: on_success
|
||||
|
||||
docker-edk2:
|
||||
extends: .edk2_job_rules
|
||||
stage: containers
|
||||
image: docker:19.03.1
|
||||
services:
|
||||
- docker:19.03.1-dind
|
||||
variables:
|
||||
GIT_DEPTH: 3
|
||||
IMAGE_TAG: $CI_REGISTRY_IMAGE:edk2-cross-build
|
||||
# We don't use TLS
|
||||
DOCKER_HOST: tcp://docker:2375
|
||||
DOCKER_TLS_CERTDIR: ""
|
||||
before_script:
|
||||
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
|
||||
script:
|
||||
- docker pull $IMAGE_TAG || true
|
||||
- docker build --cache-from $IMAGE_TAG --tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
|
||||
--tag $IMAGE_TAG .gitlab-ci.d/edk2
|
||||
- docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
|
||||
- docker push $IMAGE_TAG
|
||||
|
||||
build-edk2:
|
||||
extends: .edk2_job_rules
|
||||
stage: build
|
||||
needs: ['docker-edk2']
|
||||
artifacts:
|
||||
paths: # 'artifacts.zip' will contains the following files:
|
||||
- pc-bios/edk2*bz2
|
||||
- pc-bios/edk2-licenses.txt
|
||||
- edk2-stdout.log
|
||||
- edk2-stderr.log
|
||||
image: $CI_REGISTRY_IMAGE:edk2-cross-build
|
||||
variables:
|
||||
GIT_DEPTH: 3
|
||||
script: # Clone the required submodules and build EDK2
|
||||
- git submodule update --init roms/edk2
|
||||
- git -C roms/edk2 submodule update --init --
|
||||
ArmPkg/Library/ArmSoftFloatLib/berkeley-softfloat-3
|
||||
BaseTools/Source/C/BrotliCompress/brotli
|
||||
CryptoPkg/Library/OpensslLib/openssl
|
||||
MdeModulePkg/Library/BrotliCustomDecompressLib/brotli
|
||||
- export JOBS=$(($(getconf _NPROCESSORS_ONLN) + 1))
|
||||
- echo "=== Using ${JOBS} simultaneous jobs ==="
|
||||
- make -j${JOBS} -C roms efi 2>&1 1>edk2-stdout.log | tee -a edk2-stderr.log >&2
|
||||
@@ -0,0 +1,27 @@
|
||||
#
|
||||
# Docker image to cross-compile EDK2 firmware binaries
|
||||
#
|
||||
FROM ubuntu:18.04
|
||||
|
||||
MAINTAINER Philippe Mathieu-Daudé <[email protected]>
|
||||
|
||||
# Install packages required to build EDK2
|
||||
RUN apt update \
|
||||
&& \
|
||||
\
|
||||
DEBIAN_FRONTEND=noninteractive \
|
||||
apt install --assume-yes --no-install-recommends \
|
||||
build-essential \
|
||||
ca-certificates \
|
||||
dos2unix \
|
||||
gcc-aarch64-linux-gnu \
|
||||
gcc-arm-linux-gnueabi \
|
||||
git \
|
||||
iasl \
|
||||
make \
|
||||
nasm \
|
||||
python3 \
|
||||
uuid-dev \
|
||||
&& \
|
||||
\
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
@@ -42,9 +42,9 @@
|
||||
docker-opensbi:
|
||||
extends: .opensbi_job_rules
|
||||
stage: containers
|
||||
image: docker:stable
|
||||
image: docker:19.03.1
|
||||
services:
|
||||
- docker:stable-dind
|
||||
- docker:19.03.1-dind
|
||||
variables:
|
||||
GIT_DEPTH: 3
|
||||
IMAGE_TAG: $CI_REGISTRY_IMAGE:opensbi-cross-build
|
||||
|
||||
@@ -15,7 +15,6 @@ RUN apt update \
|
||||
ca-certificates \
|
||||
git \
|
||||
make \
|
||||
python3 \
|
||||
wget \
|
||||
&& \
|
||||
\
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
include:
|
||||
- local: '/.gitlab-ci.d/base.yml'
|
||||
- local: '/.gitlab-ci.d/stages.yml'
|
||||
- local: '/.gitlab-ci.d/edk2.yml'
|
||||
- local: '/.gitlab-ci.d/opensbi.yml'
|
||||
- local: '/.gitlab-ci.d/containers.yml'
|
||||
- local: '/.gitlab-ci.d/crossbuilds.yml'
|
||||
|
||||
@@ -23,12 +23,12 @@ check-dco:
|
||||
before_script:
|
||||
- apk -U add git
|
||||
|
||||
check-python-minreqs:
|
||||
check-python-pipenv:
|
||||
extends: .base_job_template
|
||||
stage: test
|
||||
image: $CI_REGISTRY_IMAGE/qemu/python:latest
|
||||
script:
|
||||
- make -C python check-minreqs
|
||||
- make -C python check-pipenv
|
||||
variables:
|
||||
GIT_DEPTH: 1
|
||||
needs:
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
.shared_msys2_builder:
|
||||
extends: .base_job_template
|
||||
tags:
|
||||
- saas-windows-medium-amd64
|
||||
- shared-windows
|
||||
- windows
|
||||
- windows-1809
|
||||
cache:
|
||||
key: "${CI_JOB_NAME}-cache"
|
||||
paths:
|
||||
@@ -61,3 +63,37 @@ msys2-64bit:
|
||||
--enable-capstone --without-default-devices'
|
||||
- .\msys64\usr\bin\bash -lc 'make'
|
||||
- .\msys64\usr\bin\bash -lc 'make check || { cat build/meson-logs/testlog.txt; exit 1; } ;'
|
||||
|
||||
msys2-32bit:
|
||||
extends: .shared_msys2_builder
|
||||
script:
|
||||
- .\msys64\usr\bin\bash -lc "pacman -Sy --noconfirm --needed
|
||||
bison diffutils flex
|
||||
git grep make sed
|
||||
mingw-w64-i686-capstone
|
||||
mingw-w64-i686-curl
|
||||
mingw-w64-i686-cyrus-sasl
|
||||
mingw-w64-i686-gcc
|
||||
mingw-w64-i686-glib2
|
||||
mingw-w64-i686-gnutls
|
||||
mingw-w64-i686-gtk3
|
||||
mingw-w64-i686-libgcrypt
|
||||
mingw-w64-i686-libjpeg-turbo
|
||||
mingw-w64-i686-libssh
|
||||
mingw-w64-i686-libtasn1
|
||||
mingw-w64-i686-libusb
|
||||
mingw-w64-i686-lzo2
|
||||
mingw-w64-i686-ninja
|
||||
mingw-w64-i686-pixman
|
||||
mingw-w64-i686-pkgconf
|
||||
mingw-w64-i686-python
|
||||
mingw-w64-i686-snappy
|
||||
mingw-w64-i686-usbredir "
|
||||
- $env:CHERE_INVOKING = 'yes' # Preserve the current working directory
|
||||
- $env:MSYSTEM = 'MINGW32' # Start a 32-bit MinG environment
|
||||
- $env:MSYS = 'winsymlinks:native' # Enable native Windows symlink
|
||||
- mkdir output
|
||||
- cd output
|
||||
- ..\msys64\usr\bin\bash -lc "../configure --target-list=ppc64-softmmu"
|
||||
- ..\msys64\usr\bin\bash -lc 'make'
|
||||
- ..\msys64\usr\bin\bash -lc 'make check || { cat meson-logs/testlog.txt; exit 1; } ;'
|
||||
@@ -58,6 +58,9 @@
|
||||
[submodule "roms/vbootrom"]
|
||||
path = roms/vbootrom
|
||||
url = https://gitlab.com/qemu-project/vbootrom.git
|
||||
[submodule "libucontext"]
|
||||
path = subprojects/libucontext
|
||||
url = https://github.com/utmapp/libucontext.git
|
||||
[submodule "tests/lcitool/libvirt-ci"]
|
||||
path = tests/lcitool/libvirt-ci
|
||||
url = https://gitlab.com/libvirt/libvirt-ci.git
|
||||
|
||||
+7
-12
@@ -5,21 +5,16 @@
|
||||
# Required
|
||||
version: 2
|
||||
|
||||
# Set the version of Python and other tools you might need
|
||||
build:
|
||||
os: ubuntu-22.04
|
||||
tools:
|
||||
python: "3.11"
|
||||
|
||||
# Build documentation in the docs/ directory with Sphinx
|
||||
sphinx:
|
||||
configuration: docs/conf.py
|
||||
|
||||
# We recommend specifying your dependencies to enable reproducible builds:
|
||||
# https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html
|
||||
python:
|
||||
install:
|
||||
- requirements: docs/requirements.txt
|
||||
|
||||
# We want all the document formats
|
||||
formats: all
|
||||
|
||||
# For consistency, we require that QEMU's Sphinx extensions
|
||||
# run with at least the same minimum version of Python that
|
||||
# we require for other Python in our codebase (our conf.py
|
||||
# enforces this, and some code needs it.)
|
||||
python:
|
||||
version: 3.6
|
||||
@@ -3257,6 +3257,8 @@ F: roms/edk2
|
||||
F: roms/edk2-*
|
||||
F: tests/data/uefi-boot-images/
|
||||
F: tests/uefi-test-tools/
|
||||
F: .gitlab-ci.d/edk2.yml
|
||||
F: .gitlab-ci.d/edk2/
|
||||
|
||||
VT-d Emulation
|
||||
M: Michael S. Tsirkin <[email protected]>
|
||||
|
||||
+302
-83
@@ -57,25 +57,34 @@
|
||||
#include "sysemu/hvf_int.h"
|
||||
#include "sysemu/runstate.h"
|
||||
#include "qemu/guest-random.h"
|
||||
#include "hw/boards.h"
|
||||
#include "exec/memory-remap.h"
|
||||
#include "exec/ram_addr.h"
|
||||
|
||||
HVFState *hvf_state;
|
||||
|
||||
#ifdef __aarch64__
|
||||
#define HV_VM_DEFAULT NULL
|
||||
#endif
|
||||
|
||||
/* Memory slots */
|
||||
|
||||
hvf_slot *hvf_find_overlap_slot(uint64_t start, uint64_t size)
|
||||
{
|
||||
#define HVF_MAX_SLOTS 512
|
||||
#ifdef DEBUG_HVF
|
||||
#define DPRINTF(fmt, ...) \
|
||||
do { fprintf(stdout, fmt, ## __VA_ARGS__); } while (0)
|
||||
#else
|
||||
#define DPRINTF(fmt, ...) \
|
||||
do { } while (0)
|
||||
#endif
|
||||
|
||||
#define qemu_abort(...) do { g_error(__VA_ARGS__); g_abort(); } while (0)
|
||||
|
||||
pthread_rwlock_t mem_lock = PTHREAD_RWLOCK_INITIALIZER;
|
||||
|
||||
hvf_slot *hvf_find_overlap_slot(uint64_t start, uint64_t end) {
|
||||
hvf_slot *slot;
|
||||
int x;
|
||||
for (x = 0; x < hvf_state->num_slots; ++x) {
|
||||
slot = &hvf_state->slots[x];
|
||||
if (slot->size && start < (slot->start + slot->size) &&
|
||||
(start + size) > slot->start) {
|
||||
if (slot->size && start < (slot->start + slot->size) && end > slot->start)
|
||||
return slot;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
@@ -85,22 +94,236 @@ struct mac_slot {
|
||||
uint64_t size;
|
||||
uint64_t gpa_start;
|
||||
uint64_t gva;
|
||||
void* hva;
|
||||
};
|
||||
|
||||
struct mac_slot mac_slots[32];
|
||||
struct mac_slot mac_slots[HVF_MAX_SLOTS];
|
||||
|
||||
static int do_hvf_set_memory(hvf_slot *slot, hv_memory_flags_t flags)
|
||||
{
|
||||
#define ALIGN(x, y) (((x)+(y)-1) & ~((y)-1))
|
||||
|
||||
void* hvf_gpa2hva(uint64_t gpa, bool* found) {
|
||||
struct mac_slot *mslot;
|
||||
*found = false;
|
||||
|
||||
for (uint32_t i = 0; i < HVF_MAX_SLOTS; i++) {
|
||||
mslot = &mac_slots[i];
|
||||
if (!mslot->present) continue;
|
||||
if (gpa >= mslot->gpa_start &&
|
||||
gpa < mslot->gpa_start + mslot->size) {
|
||||
*found = true;
|
||||
return (void*)((char*)(mslot->hva) + (gpa - mslot->gpa_start));
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define min(a, b) ((a) < (b) ? (a) : (b))
|
||||
int hvf_hva2gpa(void* hva, uint64_t length, int array_size,
|
||||
uint64_t* gpa, uint64_t* size) {
|
||||
struct mac_slot *mslot;
|
||||
int count = 0;
|
||||
|
||||
for (uint32_t i = 0; i < HVF_MAX_SLOTS; i++) {
|
||||
mslot = &mac_slots[i];
|
||||
if (!mslot->present) continue;
|
||||
|
||||
uintptr_t hva_start_num = (uintptr_t)mslot->hva;
|
||||
uintptr_t hva_num = (uintptr_t)hva;
|
||||
// Start of this hva region is in this slot.
|
||||
if (hva_num >= hva_start_num &&
|
||||
hva_num < hva_start_num + mslot->size) {
|
||||
if (count < array_size) {
|
||||
gpa[count] = mslot->gpa_start + (hva_num - hva_start_num);
|
||||
size[count] = min(length,
|
||||
mslot->size - (hva_num - hva_start_num));
|
||||
}
|
||||
count++;
|
||||
// End of this hva region is in this slot.
|
||||
// Its start is outside of this slot.
|
||||
} else if (hva_num + length <= hva_start_num + mslot->size &&
|
||||
hva_num + length > hva_start_num) {
|
||||
if (count < array_size) {
|
||||
gpa[count] = mslot->gpa_start;
|
||||
size[count] = hva_num + length - hva_start_num;
|
||||
}
|
||||
count++;
|
||||
// This slot belongs to this hva region completely.
|
||||
} else if (hva_num + length > hva_start_num + mslot->size &&
|
||||
hva_num < hva_start_num) {
|
||||
if (count < array_size) {
|
||||
gpa[count] = mslot->gpa_start;
|
||||
size[count] = mslot->size;
|
||||
}
|
||||
count++;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
static hvf_slot* hvf_next_free_slot() {
|
||||
hvf_slot* mem = 0;
|
||||
int x;
|
||||
|
||||
for (x = 0; x < hvf_state->num_slots; ++x) {
|
||||
mem = &hvf_state->slots[x];
|
||||
if (!mem->size) {
|
||||
return mem;
|
||||
}
|
||||
}
|
||||
|
||||
return mem;
|
||||
}
|
||||
|
||||
int __hvf_set_memory(hvf_slot *slot);
|
||||
int __hvf_set_memory_with_flags_locked(hvf_slot *slot, hv_memory_flags_t flags);
|
||||
|
||||
int hvf_map_safe(void* hva, uint64_t gpa, uint64_t size, uint64_t flags) {
|
||||
pthread_rwlock_wrlock(&mem_lock);
|
||||
DPRINTF("%s: hva: [%p 0x%llx] gpa: [0x%llx 0x%llx]\n", __func__,
|
||||
hva, (unsigned long long)(uintptr_t)(((char*)hva) + size),
|
||||
(unsigned long long)gpa,
|
||||
(unsigned long long)gpa + size);
|
||||
|
||||
hvf_slot *mem;
|
||||
mem = hvf_find_overlap_slot(gpa, gpa + size);
|
||||
|
||||
if (mem &&
|
||||
mem->mem == hva &&
|
||||
mem->start == gpa &&
|
||||
mem->size == size) {
|
||||
|
||||
pthread_rwlock_unlock(&mem_lock);
|
||||
return HV_SUCCESS;
|
||||
} else if (mem &&
|
||||
mem->start == gpa &&
|
||||
mem->size == size) {
|
||||
// unmap existing mapping, but only if it coincides
|
||||
mem->size = 0;
|
||||
__hvf_set_memory_with_flags_locked(mem, 0);
|
||||
} else if (mem) {
|
||||
// TODO: Manage and support partially-overlapping user-backed RAM mappings.
|
||||
// for now, consider it fatal.
|
||||
pthread_rwlock_unlock(&mem_lock);
|
||||
qemu_abort("%s: FATAL: tried to map [0x%llx 0x%llx) to %p "
|
||||
"while it was mapped to [0x%llx 0x%llx), %p",
|
||||
__func__,
|
||||
(unsigned long long)gpa,
|
||||
(unsigned long long)gpa + size,
|
||||
hva,
|
||||
(unsigned long long)mem->start,
|
||||
(unsigned long long)mem->start + mem->size,
|
||||
mem->mem);
|
||||
}
|
||||
|
||||
mem = hvf_next_free_slot();
|
||||
|
||||
if (mem->size) {
|
||||
qemu_abort("%s: no free slots\n", __func__);
|
||||
}
|
||||
|
||||
mem->mem = (uint8_t*)hva;
|
||||
mem->start = gpa;
|
||||
mem->size = size;
|
||||
|
||||
int res = __hvf_set_memory_with_flags_locked(mem, (hv_memory_flags_t)flags);
|
||||
|
||||
pthread_rwlock_unlock(&mem_lock);
|
||||
return res;
|
||||
}
|
||||
|
||||
int hvf_unmap_safe(uint64_t gpa, uint64_t size) {
|
||||
DPRINTF("%s: gpa: [0x%llx 0x%llx]\n", __func__,
|
||||
(unsigned long long)gpa,
|
||||
(unsigned long long)gpa + size);
|
||||
pthread_rwlock_wrlock(&mem_lock);
|
||||
|
||||
hvf_slot *mem;
|
||||
int res = 0;
|
||||
mem = hvf_find_overlap_slot(gpa, gpa + size);
|
||||
|
||||
if (mem &&
|
||||
(mem->start != gpa ||
|
||||
mem->size != size)) {
|
||||
|
||||
pthread_rwlock_unlock(&mem_lock);
|
||||
|
||||
qemu_abort("%s: tried to unmap [0x%llx 0x%llx) but partially overlapping "
|
||||
"[0x%llx 0x%llx), %p was encountered",
|
||||
__func__, gpa, gpa + size,
|
||||
mem->start, mem->start + mem->size, mem->mem);
|
||||
} else if (mem) {
|
||||
mem->size = 0;
|
||||
res = __hvf_set_memory_with_flags_locked(mem, 0);
|
||||
} else {
|
||||
// fall through, allow res to be 0 still if slot was not found.
|
||||
}
|
||||
|
||||
pthread_rwlock_unlock(&mem_lock);
|
||||
return res;
|
||||
}
|
||||
|
||||
int hvf_protect_safe(uint64_t gpa, uint64_t size, uint64_t flags) {
|
||||
pthread_rwlock_wrlock(&mem_lock);
|
||||
int res = hv_vm_protect(gpa, size, flags);
|
||||
pthread_rwlock_unlock(&mem_lock);
|
||||
return res;
|
||||
}
|
||||
|
||||
int hvf_remap_safe(void* hva, uint64_t gpa, uint64_t size, uint64_t flags) {
|
||||
pthread_rwlock_wrlock(&mem_lock);
|
||||
int res = hv_vm_unmap(gpa, size);
|
||||
assert_hvf_ok(res);
|
||||
res = hv_vm_map(hva, gpa, size, flags);
|
||||
assert_hvf_ok(res);
|
||||
pthread_rwlock_unlock(&mem_lock);
|
||||
return res;
|
||||
}
|
||||
|
||||
// API for adding and removing mappings of guest RAM and host addrs.
|
||||
// Implementation depends on the hypervisor.
|
||||
static hv_memory_flags_t user_backed_flags_to_hvf_flags(int flags) {
|
||||
hv_memory_flags_t hvf_flags = 0;
|
||||
if (flags & USER_BACKED_RAM_FLAGS_READ) {
|
||||
hvf_flags |= HV_MEMORY_READ;
|
||||
}
|
||||
if (flags & USER_BACKED_RAM_FLAGS_WRITE) {
|
||||
hvf_flags |= HV_MEMORY_WRITE;
|
||||
}
|
||||
if (flags & USER_BACKED_RAM_FLAGS_EXEC) {
|
||||
hvf_flags |= HV_MEMORY_EXEC;
|
||||
}
|
||||
return hvf_flags;
|
||||
}
|
||||
|
||||
static void hvf_user_backed_ram_map(uint64_t gpa, void* hva, uint64_t size, int flags) {
|
||||
hvf_map_safe(hva, gpa, size, user_backed_flags_to_hvf_flags(flags));
|
||||
}
|
||||
|
||||
static void hvf_user_backed_ram_unmap(uint64_t gpa, uint64_t size) {
|
||||
hvf_unmap_safe(gpa, size);
|
||||
}
|
||||
|
||||
int __hvf_set_memory(hvf_slot *slot) {
|
||||
pthread_rwlock_wrlock(&mem_lock);
|
||||
int res = __hvf_set_memory_with_flags_locked(slot, HV_MEMORY_READ | HV_MEMORY_WRITE | HV_MEMORY_EXEC);
|
||||
pthread_rwlock_unlock(&mem_lock);
|
||||
return res;
|
||||
}
|
||||
|
||||
int __hvf_set_memory_with_flags_locked(hvf_slot *slot, hv_memory_flags_t flags) {
|
||||
struct mac_slot *macslot;
|
||||
hv_return_t ret;
|
||||
|
||||
macslot = &mac_slots[slot->slot_id];
|
||||
|
||||
if (macslot->present) {
|
||||
if (macslot->size != slot->size) {
|
||||
macslot->present = 0;
|
||||
ret = hv_vm_unmap(macslot->gpa_start, macslot->size);
|
||||
assert_hvf_ok(ret);
|
||||
DPRINTF("%s: hv_vm_unmap for gpa [0x%llx 0x%llx]\n", __func__,
|
||||
(unsigned long long)macslot->gpa_start,
|
||||
(unsigned long long)(macslot->gpa_start + macslot->size));
|
||||
int unmapres = hv_vm_unmap(macslot->gpa_start, macslot->size);
|
||||
assert_hvf_ok(unmapres);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,93 +334,58 @@ static int do_hvf_set_memory(hvf_slot *slot, hv_memory_flags_t flags)
|
||||
macslot->present = 1;
|
||||
macslot->gpa_start = slot->start;
|
||||
macslot->size = slot->size;
|
||||
ret = hv_vm_map(slot->mem, slot->start, slot->size, flags);
|
||||
assert_hvf_ok(ret);
|
||||
macslot->hva = slot->mem;
|
||||
DPRINTF("%s: hv_vm_map for hva 0x%llx gpa [0x%llx 0x%llx]\n", __func__,
|
||||
(unsigned long long)(slot->mem),
|
||||
(unsigned long long)macslot->gpa_start,
|
||||
(unsigned long long)(macslot->gpa_start + macslot->size));
|
||||
int mapres = (hv_vm_map(slot->mem, slot->start, slot->size, flags));
|
||||
assert_hvf_ok(mapres);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void hvf_set_phys_mem(MemoryRegionSection *section, bool add)
|
||||
{
|
||||
static void hvf_set_phys_mem(MemoryRegionSection* section, bool add) {
|
||||
hvf_slot *mem;
|
||||
MemoryRegion *area = section->mr;
|
||||
bool writable = !area->readonly && !area->rom_device;
|
||||
hv_memory_flags_t flags;
|
||||
uint64_t page_size = qemu_real_host_page_size();
|
||||
|
||||
if (!memory_region_is_ram(area)) {
|
||||
if (writable) {
|
||||
return;
|
||||
} else if (!memory_region_is_romd(area)) {
|
||||
/*
|
||||
* If the memory device is not in romd_mode, then we actually want
|
||||
* to remove the hvf memory slot so all accesses will trap.
|
||||
*/
|
||||
add = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!QEMU_IS_ALIGNED(int128_get64(section->size), page_size) ||
|
||||
!QEMU_IS_ALIGNED(section->offset_within_address_space, page_size)) {
|
||||
/* Not page aligned, so we can not map as RAM */
|
||||
add = false;
|
||||
}
|
||||
if (!memory_region_is_ram(area)) return;
|
||||
if (memory_region_is_user_backed(area)) return;
|
||||
|
||||
mem = hvf_find_overlap_slot(
|
||||
section->offset_within_address_space,
|
||||
int128_get64(section->size));
|
||||
section->offset_within_address_space + int128_get64(section->size));
|
||||
|
||||
if (mem && add) {
|
||||
if (mem->size == int128_get64(section->size) &&
|
||||
mem->start == section->offset_within_address_space &&
|
||||
mem->mem == (memory_region_get_ram_ptr(area) +
|
||||
section->offset_within_region)) {
|
||||
return; /* Same region was attempted to register, go away. */
|
||||
}
|
||||
mem->start == section->offset_within_address_space &&
|
||||
mem->mem == (memory_region_get_ram_ptr(area) + section->offset_within_region))
|
||||
return; // Same region was attempted to register, go away.
|
||||
}
|
||||
|
||||
/* Region needs to be reset. set the size to 0 and remap it. */
|
||||
// Region needs to be reset. set the size to 0 and remap it.
|
||||
if (mem) {
|
||||
mem->size = 0;
|
||||
if (do_hvf_set_memory(mem, 0)) {
|
||||
error_report("Failed to reset overlapping slot");
|
||||
abort();
|
||||
if (__hvf_set_memory(mem)) {
|
||||
qemu_abort("%s: Failed to reset overlapping slot\n", __func__);
|
||||
}
|
||||
}
|
||||
|
||||
if (!add) {
|
||||
return;
|
||||
}
|
||||
if (!add) return;
|
||||
|
||||
if (area->readonly ||
|
||||
(!memory_region_is_ram(area) && memory_region_is_romd(area))) {
|
||||
flags = HV_MEMORY_READ | HV_MEMORY_EXEC;
|
||||
} else {
|
||||
flags = HV_MEMORY_READ | HV_MEMORY_WRITE | HV_MEMORY_EXEC;
|
||||
}
|
||||
// Now make a new slot.
|
||||
|
||||
/* Now make a new slot. */
|
||||
int x;
|
||||
mem = hvf_next_free_slot();
|
||||
|
||||
for (x = 0; x < hvf_state->num_slots; ++x) {
|
||||
mem = &hvf_state->slots[x];
|
||||
if (!mem->size) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (x == hvf_state->num_slots) {
|
||||
error_report("No free slots");
|
||||
abort();
|
||||
if (!mem) {
|
||||
qemu_abort("%s: no free slots\n", __func__);
|
||||
}
|
||||
|
||||
mem->size = int128_get64(section->size);
|
||||
mem->mem = memory_region_get_ram_ptr(area) + section->offset_within_region;
|
||||
mem->start = section->offset_within_address_space;
|
||||
mem->region = area;
|
||||
|
||||
if (do_hvf_set_memory(mem, flags)) {
|
||||
error_report("Error registering new memory slot");
|
||||
abort();
|
||||
if (__hvf_set_memory(mem)) {
|
||||
qemu_abort("%s: error regsitering new memory slot\n", __func__);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -319,25 +507,47 @@ bool hvf_allowed;
|
||||
|
||||
static int hvf_accel_init(MachineState *ms)
|
||||
{
|
||||
int x;
|
||||
hv_return_t ret;
|
||||
HVFState *s;
|
||||
HVFState *s = HVF_STATE(ms->accelerator);
|
||||
|
||||
ret = hv_vm_create(HV_VM_DEFAULT);
|
||||
ret = hvf_arch_vm_create(s);
|
||||
assert_hvf_ok(ret);
|
||||
|
||||
s = g_new0(HVFState, 1);
|
||||
hvf_state = s;
|
||||
memory_listener_register(&hvf_memory_listener, &address_space_memory);
|
||||
qemu_set_user_backed_mapping_funcs(
|
||||
hvf_user_backed_ram_map,
|
||||
hvf_user_backed_ram_unmap);
|
||||
|
||||
return hvf_arch_init();
|
||||
}
|
||||
|
||||
#if defined(CONFIG_HVF_PRIVATE) && defined(__aarch64__)
|
||||
|
||||
static bool hvf_get_tso(Object *obj, Error **errp)
|
||||
{
|
||||
HVFState *s = HVF_STATE(obj);
|
||||
return s->tso_mode;
|
||||
}
|
||||
|
||||
static void hvf_set_tso(Object *obj, bool value, Error **errp)
|
||||
{
|
||||
HVFState *s = HVF_STATE(obj);
|
||||
s->tso_mode = value;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
static void hvf_accel_instance_init(Object *obj)
|
||||
{
|
||||
int x;
|
||||
HVFState *s = HVF_STATE(obj);
|
||||
|
||||
s->num_slots = ARRAY_SIZE(s->slots);
|
||||
for (x = 0; x < s->num_slots; ++x) {
|
||||
s->slots[x].size = 0;
|
||||
s->slots[x].slot_id = x;
|
||||
}
|
||||
|
||||
hvf_state = s;
|
||||
memory_listener_register(&hvf_memory_listener, &address_space_memory);
|
||||
|
||||
return hvf_arch_init();
|
||||
}
|
||||
|
||||
static void hvf_accel_class_init(ObjectClass *oc, void *data)
|
||||
@@ -346,12 +556,21 @@ static void hvf_accel_class_init(ObjectClass *oc, void *data)
|
||||
ac->name = "HVF";
|
||||
ac->init_machine = hvf_accel_init;
|
||||
ac->allowed = &hvf_allowed;
|
||||
|
||||
#if defined(CONFIG_HVF_PRIVATE) && defined(__aarch64__)
|
||||
object_class_property_add_bool(oc, "tso",
|
||||
hvf_get_tso, hvf_set_tso);
|
||||
object_class_property_set_description(oc, "tso",
|
||||
"Set on/off to enable/disable total store ordering mode");
|
||||
#endif
|
||||
}
|
||||
|
||||
static const TypeInfo hvf_accel_type = {
|
||||
.name = TYPE_HVF_ACCEL,
|
||||
.parent = TYPE_ACCEL,
|
||||
.instance_init = hvf_accel_instance_init,
|
||||
.class_init = hvf_accel_class_init,
|
||||
.instance_size = sizeof(HVFState),
|
||||
};
|
||||
|
||||
static void hvf_type_init(void)
|
||||
|
||||
+1
-3
@@ -2294,7 +2294,7 @@ static int kvm_init(MachineState *ms)
|
||||
KVMState *s;
|
||||
const KVMCapabilityInfo *missing_cap;
|
||||
int ret;
|
||||
int type;
|
||||
int type = 0;
|
||||
uint64_t dirty_log_manual_caps;
|
||||
|
||||
qemu_mutex_init(&kml_slots_lock);
|
||||
@@ -2358,8 +2358,6 @@ static int kvm_init(MachineState *ms)
|
||||
type = mc->kvm_type(ms, kvm_type);
|
||||
} else if (mc->kvm_type) {
|
||||
type = mc->kvm_type(ms, NULL);
|
||||
} else {
|
||||
type = kvm_arch_get_default_type(ms);
|
||||
}
|
||||
|
||||
do {
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include "disas/disas.h"
|
||||
#include "exec/exec-all.h"
|
||||
#include "tcg/tcg.h"
|
||||
#include "tcg/tcg-apple-jit.h"
|
||||
#include "qemu/atomic.h"
|
||||
#include "qemu/compiler.h"
|
||||
#include "qemu/timer.h"
|
||||
@@ -186,7 +187,7 @@ static bool tb_lookup_cmp(const void *p, const void *d)
|
||||
const TranslationBlock *tb = p;
|
||||
const struct tb_desc *desc = d;
|
||||
|
||||
if (tb_pc(tb) == desc->pc &&
|
||||
if ((TARGET_TB_PCREL || tb_pc(tb) == desc->pc) &&
|
||||
tb_page_addr0(tb) == desc->page_addr0 &&
|
||||
tb->cs_base == desc->cs_base &&
|
||||
tb->flags == desc->flags &&
|
||||
@@ -238,7 +239,7 @@ static TranslationBlock *tb_htable_lookup(CPUState *cpu, target_ulong pc,
|
||||
return NULL;
|
||||
}
|
||||
desc.page_addr0 = phys_pc;
|
||||
h = tb_hash_func(phys_pc, pc,
|
||||
h = tb_hash_func(phys_pc, (TARGET_TB_PCREL ? 0 : pc),
|
||||
flags, cflags, *cpu->trace_dstate);
|
||||
return qht_lookup_custom(&tb_ctx.htable, &desc, h, tb_lookup_cmp);
|
||||
}
|
||||
|
||||
+1
-1
@@ -1817,7 +1817,7 @@ static void *atomic_mmu_lookup(CPUArchState *env, target_ulong addr,
|
||||
} else /* if (prot & PAGE_READ) */ {
|
||||
tlb_addr = tlbe->addr_read;
|
||||
if (!tlb_hit(tlb_addr, addr)) {
|
||||
if (!VICTIM_TLB_HIT(addr_read, addr)) {
|
||||
if (!VICTIM_TLB_HIT(addr_write, addr)) {
|
||||
tlb_fill(env_cpu(env), addr, size,
|
||||
MMU_DATA_LOAD, mmu_idx, retaddr);
|
||||
index = tlb_index(env, mmu_idx, addr);
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "exec/translate-all.h"
|
||||
#include "sysemu/tcg.h"
|
||||
#include "tcg/tcg.h"
|
||||
#include "tcg/tcg-apple-jit.h"
|
||||
#include "tb-hash.h"
|
||||
#include "tb-context.h"
|
||||
#include "internal.h"
|
||||
@@ -34,7 +35,7 @@ static bool tb_cmp(const void *ap, const void *bp)
|
||||
const TranslationBlock *a = ap;
|
||||
const TranslationBlock *b = bp;
|
||||
|
||||
return (tb_pc(a) == tb_pc(b) &&
|
||||
return ((TARGET_TB_PCREL || tb_pc(a) == tb_pc(b)) &&
|
||||
a->cs_base == b->cs_base &&
|
||||
a->flags == b->flags &&
|
||||
(tb_cflags(a) & ~CF_INVALID) == (tb_cflags(b) & ~CF_INVALID) &&
|
||||
@@ -269,7 +270,7 @@ static void do_tb_phys_invalidate(TranslationBlock *tb, bool rm_from_page_list)
|
||||
|
||||
/* remove the TB from the hash list */
|
||||
phys_pc = tb_page_addr0(tb);
|
||||
h = tb_hash_func(phys_pc, tb_pc(tb),
|
||||
h = tb_hash_func(phys_pc, (TARGET_TB_PCREL ? 0 : tb_pc(tb)),
|
||||
tb->flags, orig_cflags, tb->trace_vcpu_dstate);
|
||||
if (!qht_remove(&tb_ctx.htable, tb, h)) {
|
||||
return;
|
||||
@@ -459,7 +460,7 @@ TranslationBlock *tb_link_page(TranslationBlock *tb, tb_page_addr_t phys_pc,
|
||||
}
|
||||
|
||||
/* add in the hash table */
|
||||
h = tb_hash_func(phys_pc, tb_pc(tb),
|
||||
h = tb_hash_func(phys_pc, (TARGET_TB_PCREL ? 0 : tb_pc(tb)),
|
||||
tb->flags, tb->cflags, tb->trace_vcpu_dstate);
|
||||
qht_insert(&tb_ctx.htable, tb, h, &existing_tb);
|
||||
|
||||
|
||||
@@ -100,9 +100,14 @@ static void *mttcg_cpu_thread_fn(void *arg)
|
||||
break;
|
||||
case EXCP_HALTED:
|
||||
/*
|
||||
* Usually cpu->halted is set, but may have already been
|
||||
* reset by another thread by the time we arrive here.
|
||||
* during start-up the vCPU is reset and the thread is
|
||||
* kicked several times. If we don't ensure we go back
|
||||
* to sleep in the halted state we won't cleanly
|
||||
* start-up when the vCPU is enabled.
|
||||
*
|
||||
* cpu->halted should ensure we sleep in wait_io_event
|
||||
*/
|
||||
g_assert(cpu->halted);
|
||||
break;
|
||||
case EXCP_ATOMIC:
|
||||
qemu_mutex_unlock_iothread();
|
||||
|
||||
@@ -47,6 +47,11 @@ void tcg_cpu_init_cflags(CPUState *cpu, bool parallel)
|
||||
uint32_t cflags = cpu->cluster_index << CF_CLUSTER_SHIFT;
|
||||
cflags |= parallel ? CF_PARALLEL : 0;
|
||||
cflags |= icount_enabled() ? CF_USE_ICOUNT : 0;
|
||||
#if defined(CONFIG_TCG_THREADED_INTERPRETER)
|
||||
// GOTO_PTR is too complex to emit a simple gadget for.
|
||||
// We'll let C handle it, since the overhead is similar.
|
||||
cflags |= CF_NO_GOTO_PTR;
|
||||
#endif
|
||||
cpu->tcg_cflags = cflags;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "disas/disas.h"
|
||||
#include "exec/exec-all.h"
|
||||
#include "tcg/tcg.h"
|
||||
#include "tcg/tcg-apple-jit.h"
|
||||
#if defined(CONFIG_USER_ONLY)
|
||||
#include "qemu.h"
|
||||
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
|
||||
@@ -818,7 +819,9 @@ TranslationBlock *tb_gen_code(CPUState *cpu,
|
||||
|
||||
gen_code_buf = tcg_ctx->code_gen_ptr;
|
||||
tb->tc.ptr = tcg_splitwx_to_rx(gen_code_buf);
|
||||
#if !TARGET_TB_PCREL
|
||||
tb->pc = pc;
|
||||
#endif
|
||||
tb->cs_base = cs_base;
|
||||
tb->flags = flags;
|
||||
tb->cflags = cflags;
|
||||
|
||||
+24
-6
@@ -1409,12 +1409,21 @@ void audio_run(AudioState *s, const char *msg)
|
||||
#endif
|
||||
}
|
||||
|
||||
void audio_generic_initialize_buffer_in(HWVoiceIn *hw)
|
||||
{
|
||||
if (hw->buf_emul) {
|
||||
g_free(hw->buf_emul);
|
||||
}
|
||||
|
||||
hw->size_emul = hw->samples * hw->info.bytes_per_frame;
|
||||
hw->buf_emul = g_malloc(hw->size_emul);
|
||||
hw->pos_emul = hw->pending_emul = 0;
|
||||
}
|
||||
|
||||
void audio_generic_run_buffer_in(HWVoiceIn *hw)
|
||||
{
|
||||
if (unlikely(!hw->buf_emul)) {
|
||||
hw->size_emul = hw->samples * hw->info.bytes_per_frame;
|
||||
hw->buf_emul = g_malloc(hw->size_emul);
|
||||
hw->pos_emul = hw->pending_emul = 0;
|
||||
audio_generic_initialize_buffer_in(hw);
|
||||
}
|
||||
|
||||
while (hw->pending_emul < hw->size_emul) {
|
||||
@@ -1448,6 +1457,17 @@ void audio_generic_put_buffer_in(HWVoiceIn *hw, void *buf, size_t size)
|
||||
hw->pending_emul -= size;
|
||||
}
|
||||
|
||||
void audio_generic_initialize_buffer_out(HWVoiceOut *hw)
|
||||
{
|
||||
if (hw->buf_emul) {
|
||||
g_free(hw->buf_emul);
|
||||
}
|
||||
|
||||
hw->size_emul = hw->samples * hw->info.bytes_per_frame;
|
||||
hw->buf_emul = g_malloc(hw->size_emul);
|
||||
hw->pos_emul = hw->pending_emul = 0;
|
||||
}
|
||||
|
||||
size_t audio_generic_buffer_get_free(HWVoiceOut *hw)
|
||||
{
|
||||
if (hw->buf_emul) {
|
||||
@@ -1479,9 +1499,7 @@ void audio_generic_run_buffer_out(HWVoiceOut *hw)
|
||||
void *audio_generic_get_buffer_out(HWVoiceOut *hw, size_t *size)
|
||||
{
|
||||
if (unlikely(!hw->buf_emul)) {
|
||||
hw->size_emul = hw->samples * hw->info.bytes_per_frame;
|
||||
hw->buf_emul = g_malloc(hw->size_emul);
|
||||
hw->pos_emul = hw->pending_emul = 0;
|
||||
audio_generic_initialize_buffer_out(hw);
|
||||
}
|
||||
|
||||
*size = MIN(hw->size_emul - hw->pending_emul,
|
||||
|
||||
@@ -190,9 +190,11 @@ struct audio_pcm_ops {
|
||||
void (*volume_in)(HWVoiceIn *hw, Volume *vol);
|
||||
};
|
||||
|
||||
void audio_generic_initialize_buffer_in(HWVoiceIn *hw);
|
||||
void audio_generic_run_buffer_in(HWVoiceIn *hw);
|
||||
void *audio_generic_get_buffer_in(HWVoiceIn *hw, size_t *size);
|
||||
void audio_generic_put_buffer_in(HWVoiceIn *hw, void *buf, size_t size);
|
||||
void audio_generic_initialize_buffer_out(HWVoiceOut *hw);
|
||||
void audio_generic_run_buffer_out(HWVoiceOut *hw);
|
||||
size_t audio_generic_buffer_get_free(HWVoiceOut *hw);
|
||||
void *audio_generic_get_buffer_out(HWVoiceOut *hw, size_t *size);
|
||||
|
||||
+28
-22
@@ -360,7 +360,10 @@ static OSStatus audioDeviceIOProc(
|
||||
static OSStatus init_out_device(coreaudioVoiceOut *core)
|
||||
{
|
||||
OSStatus status;
|
||||
AudioDeviceID deviceID;
|
||||
AudioValueRange frameRange;
|
||||
UInt32 audioDevicePropertyBufferFrameSize;
|
||||
AudioDeviceIOProcID ioprocid;
|
||||
|
||||
AudioStreamBasicDescription streamBasicDescription = {
|
||||
.mBitsPerChannel = core->hw.info.bits,
|
||||
@@ -373,20 +376,19 @@ static OSStatus init_out_device(coreaudioVoiceOut *core)
|
||||
.mSampleRate = core->hw.info.freq
|
||||
};
|
||||
|
||||
status = coreaudio_get_voice(&core->outputDeviceID);
|
||||
status = coreaudio_get_voice(&deviceID);
|
||||
if (status != kAudioHardwareNoError) {
|
||||
coreaudio_playback_logerr (status,
|
||||
"Could not get default output Device\n");
|
||||
return status;
|
||||
}
|
||||
if (core->outputDeviceID == kAudioDeviceUnknown) {
|
||||
if (deviceID == kAudioDeviceUnknown) {
|
||||
dolog ("Could not initialize playback - Unknown Audiodevice\n");
|
||||
return status;
|
||||
}
|
||||
|
||||
/* get minimum and maximum buffer frame sizes */
|
||||
status = coreaudio_get_framesizerange(core->outputDeviceID,
|
||||
&frameRange);
|
||||
status = coreaudio_get_framesizerange(deviceID, &frameRange);
|
||||
if (status == kAudioHardwareBadObjectError) {
|
||||
return 0;
|
||||
}
|
||||
@@ -397,31 +399,31 @@ static OSStatus init_out_device(coreaudioVoiceOut *core)
|
||||
}
|
||||
|
||||
if (frameRange.mMinimum > core->frameSizeSetting) {
|
||||
core->audioDevicePropertyBufferFrameSize = (UInt32) frameRange.mMinimum;
|
||||
audioDevicePropertyBufferFrameSize = (UInt32) frameRange.mMinimum;
|
||||
dolog ("warning: Upsizing Buffer Frames to %f\n", frameRange.mMinimum);
|
||||
} else if (frameRange.mMaximum < core->frameSizeSetting) {
|
||||
core->audioDevicePropertyBufferFrameSize = (UInt32) frameRange.mMaximum;
|
||||
audioDevicePropertyBufferFrameSize = (UInt32) frameRange.mMaximum;
|
||||
dolog ("warning: Downsizing Buffer Frames to %f\n", frameRange.mMaximum);
|
||||
} else {
|
||||
core->audioDevicePropertyBufferFrameSize = core->frameSizeSetting;
|
||||
audioDevicePropertyBufferFrameSize = core->frameSizeSetting;
|
||||
}
|
||||
|
||||
/* set Buffer Frame Size */
|
||||
status = coreaudio_set_framesize(core->outputDeviceID,
|
||||
&core->audioDevicePropertyBufferFrameSize);
|
||||
status = coreaudio_set_framesize(deviceID,
|
||||
&audioDevicePropertyBufferFrameSize);
|
||||
if (status == kAudioHardwareBadObjectError) {
|
||||
return 0;
|
||||
}
|
||||
if (status != kAudioHardwareNoError) {
|
||||
coreaudio_playback_logerr (status,
|
||||
"Could not set device buffer frame size %" PRIu32 "\n",
|
||||
(uint32_t)core->audioDevicePropertyBufferFrameSize);
|
||||
(uint32_t)audioDevicePropertyBufferFrameSize);
|
||||
return status;
|
||||
}
|
||||
|
||||
/* get Buffer Frame Size */
|
||||
status = coreaudio_get_framesize(core->outputDeviceID,
|
||||
&core->audioDevicePropertyBufferFrameSize);
|
||||
status = coreaudio_get_framesize(deviceID,
|
||||
&audioDevicePropertyBufferFrameSize);
|
||||
if (status == kAudioHardwareBadObjectError) {
|
||||
return 0;
|
||||
}
|
||||
@@ -430,11 +432,9 @@ static OSStatus init_out_device(coreaudioVoiceOut *core)
|
||||
"Could not get device buffer frame size\n");
|
||||
return status;
|
||||
}
|
||||
core->hw.samples = core->bufferCount * core->audioDevicePropertyBufferFrameSize;
|
||||
|
||||
/* set Samplerate */
|
||||
status = coreaudio_set_streamformat(core->outputDeviceID,
|
||||
&streamBasicDescription);
|
||||
status = coreaudio_set_streamformat(deviceID, &streamBasicDescription);
|
||||
if (status == kAudioHardwareBadObjectError) {
|
||||
return 0;
|
||||
}
|
||||
@@ -442,7 +442,6 @@ static OSStatus init_out_device(coreaudioVoiceOut *core)
|
||||
coreaudio_playback_logerr (status,
|
||||
"Could not set samplerate %lf\n",
|
||||
streamBasicDescription.mSampleRate);
|
||||
core->outputDeviceID = kAudioDeviceUnknown;
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -456,20 +455,25 @@ static OSStatus init_out_device(coreaudioVoiceOut *core)
|
||||
* Therefore, the specified callback must be designed to avoid a deadlock
|
||||
* with the callers of AudioObjectGetPropertyData.
|
||||
*/
|
||||
core->ioprocid = NULL;
|
||||
status = AudioDeviceCreateIOProcID(core->outputDeviceID,
|
||||
ioprocid = NULL;
|
||||
status = AudioDeviceCreateIOProcID(deviceID,
|
||||
audioDeviceIOProc,
|
||||
&core->hw,
|
||||
&core->ioprocid);
|
||||
&ioprocid);
|
||||
if (status == kAudioHardwareBadDeviceError) {
|
||||
return 0;
|
||||
}
|
||||
if (status != kAudioHardwareNoError || core->ioprocid == NULL) {
|
||||
if (status != kAudioHardwareNoError || ioprocid == NULL) {
|
||||
coreaudio_playback_logerr (status, "Could not set IOProc\n");
|
||||
core->outputDeviceID = kAudioDeviceUnknown;
|
||||
return status;
|
||||
}
|
||||
|
||||
core->outputDeviceID = deviceID;
|
||||
core->audioDevicePropertyBufferFrameSize = audioDevicePropertyBufferFrameSize;
|
||||
core->hw.samples = core->bufferCount * core->audioDevicePropertyBufferFrameSize;
|
||||
audio_generic_initialize_buffer_out(&core->hw);
|
||||
core->ioprocid = ioprocid;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -553,7 +557,9 @@ static OSStatus handle_voice_change(
|
||||
fini_out_device(core);
|
||||
}
|
||||
|
||||
if (!init_out_device(core)) {
|
||||
init_out_device(core);
|
||||
|
||||
if (core->outputDeviceID) {
|
||||
update_device_playback_state(core);
|
||||
}
|
||||
|
||||
|
||||
+1
-2
@@ -29,8 +29,7 @@ endforeach
|
||||
|
||||
if dbus_display
|
||||
module_ss = ss.source_set()
|
||||
module_ss.add(when: [gio, dbus_display1_dep],
|
||||
if_true: files('dbusaudio.c'))
|
||||
module_ss.add(when: gio, if_true: files('dbusaudio.c'))
|
||||
audio_modules += {'dbus': module_ss}
|
||||
endif
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
|
||||
#include "qemu/osdep.h"
|
||||
#include "sysemu/cryptodev.h"
|
||||
#include "qemu/error-report.h"
|
||||
#include "qapi/error.h"
|
||||
#include "standard-headers/linux/virtio_crypto.h"
|
||||
#include "crypto/cipher.h"
|
||||
@@ -386,8 +385,8 @@ static int cryptodev_builtin_create_session(
|
||||
case VIRTIO_CRYPTO_HASH_CREATE_SESSION:
|
||||
case VIRTIO_CRYPTO_MAC_CREATE_SESSION:
|
||||
default:
|
||||
error_report("Unsupported opcode :%" PRIu32 "",
|
||||
sess_info->op_code);
|
||||
error_setg(&local_error, "Unsupported opcode :%" PRIu32 "",
|
||||
sess_info->op_code);
|
||||
return -VIRTIO_CRYPTO_NOTSUPP;
|
||||
}
|
||||
|
||||
@@ -417,9 +416,7 @@ static int cryptodev_builtin_close_session(
|
||||
CRYPTODEV_BACKEND_BUILTIN(backend);
|
||||
CryptoDevBackendBuiltinSession *session;
|
||||
|
||||
if (session_id >= MAX_NUM_SESSIONS || !builtin->sessions[session_id]) {
|
||||
return -VIRTIO_CRYPTO_INVSESS;
|
||||
}
|
||||
assert(session_id < MAX_NUM_SESSIONS && builtin->sessions[session_id]);
|
||||
|
||||
session = builtin->sessions[session_id];
|
||||
if (session->cipher) {
|
||||
@@ -547,8 +544,8 @@ static int cryptodev_builtin_operation(
|
||||
|
||||
if (op_info->session_id >= MAX_NUM_SESSIONS ||
|
||||
builtin->sessions[op_info->session_id] == NULL) {
|
||||
error_report("Cannot find a valid session id: %" PRIu64 "",
|
||||
op_info->session_id);
|
||||
error_setg(&local_error, "Cannot find a valid session id: %" PRIu64 "",
|
||||
op_info->session_id);
|
||||
return -VIRTIO_CRYPTO_INVSESS;
|
||||
}
|
||||
|
||||
|
||||
@@ -112,8 +112,12 @@ static int tpm_util_request(int fd,
|
||||
void *response,
|
||||
size_t responselen)
|
||||
{
|
||||
GPollFD fds[1] = { {.fd = fd, .events = G_IO_IN } };
|
||||
fd_set readfds;
|
||||
int n;
|
||||
struct timeval tv = {
|
||||
.tv_sec = 1,
|
||||
.tv_usec = 0,
|
||||
};
|
||||
|
||||
n = write(fd, request, requestlen);
|
||||
if (n < 0) {
|
||||
@@ -123,8 +127,11 @@ static int tpm_util_request(int fd,
|
||||
return -EFAULT;
|
||||
}
|
||||
|
||||
FD_ZERO(&readfds);
|
||||
FD_SET(fd, &readfds);
|
||||
|
||||
/* wait for a second */
|
||||
TFR(n = g_poll(fds, 1, 1000));
|
||||
n = select(fd + 1, &readfds, NULL, NULL, &tv);
|
||||
if (n != 1) {
|
||||
return -errno;
|
||||
}
|
||||
|
||||
@@ -85,7 +85,6 @@ static BlockDriverState *bdrv_open_inherit(const char *filename,
|
||||
BlockDriverState *parent,
|
||||
const BdrvChildClass *child_class,
|
||||
BdrvChildRole child_role,
|
||||
bool parse_filename,
|
||||
Error **errp);
|
||||
|
||||
static bool bdrv_recurse_has_child(BlockDriverState *bs,
|
||||
@@ -2052,8 +2051,7 @@ static void parse_json_protocol(QDict *options, const char **pfilename,
|
||||
* block driver has been specified explicitly.
|
||||
*/
|
||||
static int bdrv_fill_options(QDict **options, const char *filename,
|
||||
int *flags, bool allow_parse_filename,
|
||||
Error **errp)
|
||||
int *flags, Error **errp)
|
||||
{
|
||||
const char *drvname;
|
||||
bool protocol = *flags & BDRV_O_PROTOCOL;
|
||||
@@ -2095,7 +2093,7 @@ static int bdrv_fill_options(QDict **options, const char *filename,
|
||||
if (protocol && filename) {
|
||||
if (!qdict_haskey(*options, "filename")) {
|
||||
qdict_put_str(*options, "filename", filename);
|
||||
parse_filename = allow_parse_filename;
|
||||
parse_filename = true;
|
||||
} else {
|
||||
error_setg(errp, "Can't specify 'file' and 'filename' options at "
|
||||
"the same time");
|
||||
@@ -3518,8 +3516,7 @@ int bdrv_open_backing_file(BlockDriverState *bs, QDict *parent_options,
|
||||
}
|
||||
|
||||
backing_hd = bdrv_open_inherit(backing_filename, reference, options, 0, bs,
|
||||
&child_of_bds, bdrv_backing_role(bs), true,
|
||||
errp);
|
||||
&child_of_bds, bdrv_backing_role(bs), errp);
|
||||
if (!backing_hd) {
|
||||
bs->open_flags |= BDRV_O_NO_BACKING;
|
||||
error_prepend(errp, "Could not open backing file: ");
|
||||
@@ -3552,8 +3549,7 @@ free_exit:
|
||||
static BlockDriverState *
|
||||
bdrv_open_child_bs(const char *filename, QDict *options, const char *bdref_key,
|
||||
BlockDriverState *parent, const BdrvChildClass *child_class,
|
||||
BdrvChildRole child_role, bool allow_none,
|
||||
bool parse_filename, Error **errp)
|
||||
BdrvChildRole child_role, bool allow_none, Error **errp)
|
||||
{
|
||||
BlockDriverState *bs = NULL;
|
||||
QDict *image_options;
|
||||
@@ -3584,8 +3580,7 @@ bdrv_open_child_bs(const char *filename, QDict *options, const char *bdref_key,
|
||||
}
|
||||
|
||||
bs = bdrv_open_inherit(filename, reference, image_options, 0,
|
||||
parent, child_class, child_role, parse_filename,
|
||||
errp);
|
||||
parent, child_class, child_role, errp);
|
||||
if (!bs) {
|
||||
goto done;
|
||||
}
|
||||
@@ -3595,28 +3590,6 @@ done:
|
||||
return bs;
|
||||
}
|
||||
|
||||
static BdrvChild *bdrv_open_child_common(const char *filename,
|
||||
QDict *options, const char *bdref_key,
|
||||
BlockDriverState *parent,
|
||||
const BdrvChildClass *child_class,
|
||||
BdrvChildRole child_role,
|
||||
bool allow_none, bool parse_filename,
|
||||
Error **errp)
|
||||
{
|
||||
BlockDriverState *bs;
|
||||
|
||||
GLOBAL_STATE_CODE();
|
||||
|
||||
bs = bdrv_open_child_bs(filename, options, bdref_key, parent, child_class,
|
||||
child_role, allow_none, parse_filename, errp);
|
||||
if (bs == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return bdrv_attach_child(parent, bs, bdref_key, child_class, child_role,
|
||||
errp);
|
||||
}
|
||||
|
||||
/*
|
||||
* Opens a disk image whose options are given as BlockdevRef in another block
|
||||
* device's options.
|
||||
@@ -3638,9 +3611,18 @@ BdrvChild *bdrv_open_child(const char *filename,
|
||||
BdrvChildRole child_role,
|
||||
bool allow_none, Error **errp)
|
||||
{
|
||||
return bdrv_open_child_common(filename, options, bdref_key, parent,
|
||||
child_class, child_role, allow_none, false,
|
||||
errp);
|
||||
BlockDriverState *bs;
|
||||
|
||||
GLOBAL_STATE_CODE();
|
||||
|
||||
bs = bdrv_open_child_bs(filename, options, bdref_key, parent, child_class,
|
||||
child_role, allow_none, errp);
|
||||
if (bs == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return bdrv_attach_child(parent, bs, bdref_key, child_class, child_role,
|
||||
errp);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -3657,8 +3639,8 @@ int bdrv_open_file_child(const char *filename,
|
||||
role = parent->drv->is_filter ?
|
||||
(BDRV_CHILD_FILTERED | BDRV_CHILD_PRIMARY) : BDRV_CHILD_IMAGE;
|
||||
|
||||
if (!bdrv_open_child_common(filename, options, bdref_key, parent,
|
||||
&child_of_bds, role, false, true, errp))
|
||||
if (!bdrv_open_child(filename, options, bdref_key, parent,
|
||||
&child_of_bds, role, false, errp))
|
||||
{
|
||||
return -EINVAL;
|
||||
}
|
||||
@@ -3703,8 +3685,7 @@ BlockDriverState *bdrv_open_blockdev_ref(BlockdevRef *ref, Error **errp)
|
||||
|
||||
}
|
||||
|
||||
bs = bdrv_open_inherit(NULL, reference, qdict, 0, NULL, NULL, 0, false,
|
||||
errp);
|
||||
bs = bdrv_open_inherit(NULL, reference, qdict, 0, NULL, NULL, 0, errp);
|
||||
obj = NULL;
|
||||
qobject_unref(obj);
|
||||
visit_free(v);
|
||||
@@ -3794,7 +3775,7 @@ static BlockDriverState *bdrv_open_inherit(const char *filename,
|
||||
BlockDriverState *parent,
|
||||
const BdrvChildClass *child_class,
|
||||
BdrvChildRole child_role,
|
||||
bool parse_filename, Error **errp)
|
||||
Error **errp)
|
||||
{
|
||||
int ret;
|
||||
BlockBackend *file = NULL;
|
||||
@@ -3838,11 +3819,9 @@ static BlockDriverState *bdrv_open_inherit(const char *filename,
|
||||
}
|
||||
|
||||
/* json: syntax counts as explicit options, as if in the QDict */
|
||||
if (parse_filename) {
|
||||
parse_json_protocol(options, &filename, &local_err);
|
||||
if (local_err) {
|
||||
goto fail;
|
||||
}
|
||||
parse_json_protocol(options, &filename, &local_err);
|
||||
if (local_err) {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
bs->explicit_options = qdict_clone_shallow(options);
|
||||
@@ -3867,8 +3846,7 @@ static BlockDriverState *bdrv_open_inherit(const char *filename,
|
||||
parent->open_flags, parent->options);
|
||||
}
|
||||
|
||||
ret = bdrv_fill_options(&options, filename, &flags, parse_filename,
|
||||
&local_err);
|
||||
ret = bdrv_fill_options(&options, filename, &flags, &local_err);
|
||||
if (ret < 0) {
|
||||
goto fail;
|
||||
}
|
||||
@@ -3937,7 +3915,7 @@ static BlockDriverState *bdrv_open_inherit(const char *filename,
|
||||
|
||||
file_bs = bdrv_open_child_bs(filename, options, "file", bs,
|
||||
&child_of_bds, BDRV_CHILD_IMAGE,
|
||||
true, true, &local_err);
|
||||
true, &local_err);
|
||||
if (local_err) {
|
||||
goto fail;
|
||||
}
|
||||
@@ -4084,7 +4062,7 @@ BlockDriverState *bdrv_open(const char *filename, const char *reference,
|
||||
GLOBAL_STATE_CODE();
|
||||
|
||||
return bdrv_open_inherit(filename, reference, options, flags, NULL,
|
||||
NULL, 0, true, errp);
|
||||
NULL, 0, errp);
|
||||
}
|
||||
|
||||
/* Return true if the NULL-terminated @list contains @str */
|
||||
|
||||
+1
-1
@@ -74,7 +74,7 @@ typedef struct {
|
||||
CoQueue bounce_available;
|
||||
|
||||
/* The value of the "mem-region-alignment" property */
|
||||
uint64_t mem_region_alignment;
|
||||
size_t mem_region_alignment;
|
||||
|
||||
/* Can we skip adding/deleting blkio_mem_regions? */
|
||||
bool needs_mem_regions;
|
||||
|
||||
+8
-25
@@ -321,39 +321,22 @@ typedef struct {
|
||||
static void coroutine_fn blk_log_writes_co_do_log(BlkLogWritesLogReq *lr)
|
||||
{
|
||||
BDRVBlkLogWritesState *s = lr->bs->opaque;
|
||||
|
||||
/*
|
||||
* Determine the offsets and sizes of different parts of the entry, and
|
||||
* update the state of the driver.
|
||||
*
|
||||
* This needs to be done in one go, before any actual I/O is done, as the
|
||||
* log entry may have to be written in two parts, and the state of the
|
||||
* driver may be modified by other driver operations while waiting for the
|
||||
* I/O to complete.
|
||||
*/
|
||||
const uint64_t entry_start_sector = s->cur_log_sector;
|
||||
const uint64_t entry_offset = entry_start_sector << s->sectorbits;
|
||||
const uint64_t qiov_aligned_size = ROUND_UP(lr->qiov->size, s->sectorsize);
|
||||
const uint64_t entry_aligned_size = qiov_aligned_size +
|
||||
ROUND_UP(lr->zero_size, s->sectorsize);
|
||||
const uint64_t entry_nr_sectors = entry_aligned_size >> s->sectorbits;
|
||||
uint64_t cur_log_offset = s->cur_log_sector << s->sectorbits;
|
||||
|
||||
s->nr_entries++;
|
||||
s->cur_log_sector += entry_nr_sectors;
|
||||
s->cur_log_sector +=
|
||||
ROUND_UP(lr->qiov->size, s->sectorsize) >> s->sectorbits;
|
||||
|
||||
/*
|
||||
* Write the log entry. Note that if this is a "write zeroes" operation,
|
||||
* only the entry header is written here, with the zeroing being done
|
||||
* separately below.
|
||||
*/
|
||||
lr->log_ret = bdrv_co_pwritev(s->log_file, entry_offset, lr->qiov->size,
|
||||
lr->log_ret = bdrv_co_pwritev(s->log_file, cur_log_offset, lr->qiov->size,
|
||||
lr->qiov, 0);
|
||||
|
||||
/* Logging for the "write zeroes" operation */
|
||||
if (lr->log_ret == 0 && lr->zero_size) {
|
||||
const uint64_t zeroes_offset = entry_offset + qiov_aligned_size;
|
||||
cur_log_offset = s->cur_log_sector << s->sectorbits;
|
||||
s->cur_log_sector +=
|
||||
ROUND_UP(lr->zero_size, s->sectorsize) >> s->sectorbits;
|
||||
|
||||
lr->log_ret = bdrv_co_pwrite_zeroes(s->log_file, zeroes_offset,
|
||||
lr->log_ret = bdrv_co_pwrite_zeroes(s->log_file, cur_log_offset,
|
||||
lr->zero_size, 0);
|
||||
}
|
||||
|
||||
|
||||
+7
-37
@@ -37,15 +37,8 @@
|
||||
|
||||
// #define DEBUG_VERBOSE
|
||||
|
||||
/* CURL 7.85.0 switches to a string based API for specifying
|
||||
* the desired protocols.
|
||||
*/
|
||||
#if LIBCURL_VERSION_NUM >= 0x075500
|
||||
#define PROTOCOLS "HTTP,HTTPS,FTP,FTPS"
|
||||
#else
|
||||
#define PROTOCOLS (CURLPROTO_HTTP | CURLPROTO_HTTPS | \
|
||||
CURLPROTO_FTP | CURLPROTO_FTPS)
|
||||
#endif
|
||||
|
||||
#define CURL_NUM_STATES 8
|
||||
#define CURL_NUM_ACB 8
|
||||
@@ -516,18 +509,9 @@ static int curl_init_state(BDRVCURLState *s, CURLState *state)
|
||||
* obscure protocols. For example, do not allow POP3/SMTP/IMAP see
|
||||
* CVE-2013-0249.
|
||||
*
|
||||
* Restricting protocols is only supported from 7.19.4 upwards. Note:
|
||||
* version 7.85.0 deprecates CURLOPT_*PROTOCOLS in favour of a string
|
||||
* based CURLOPT_*PROTOCOLS_STR API.
|
||||
* Restricting protocols is only supported from 7.19.4 upwards.
|
||||
*/
|
||||
#if LIBCURL_VERSION_NUM >= 0x075500
|
||||
if (curl_easy_setopt(state->curl,
|
||||
CURLOPT_PROTOCOLS_STR, PROTOCOLS) ||
|
||||
curl_easy_setopt(state->curl,
|
||||
CURLOPT_REDIR_PROTOCOLS_STR, PROTOCOLS)) {
|
||||
goto err;
|
||||
}
|
||||
#elif LIBCURL_VERSION_NUM >= 0x071304
|
||||
#if LIBCURL_VERSION_NUM >= 0x071304
|
||||
if (curl_easy_setopt(state->curl, CURLOPT_PROTOCOLS, PROTOCOLS) ||
|
||||
curl_easy_setopt(state->curl, CURLOPT_REDIR_PROTOCOLS, PROTOCOLS)) {
|
||||
goto err;
|
||||
@@ -685,12 +669,7 @@ static int curl_open(BlockDriverState *bs, QDict *options, int flags,
|
||||
const char *file;
|
||||
const char *cookie;
|
||||
const char *cookie_secret;
|
||||
/* CURL >= 7.55.0 uses curl_off_t for content length instead of a double */
|
||||
#if LIBCURL_VERSION_NUM >= 0x073700
|
||||
curl_off_t cl;
|
||||
#else
|
||||
double cl;
|
||||
#endif
|
||||
double d;
|
||||
const char *secretid;
|
||||
const char *protocol_delimiter;
|
||||
int ret;
|
||||
@@ -817,36 +796,27 @@ static int curl_open(BlockDriverState *bs, QDict *options, int flags,
|
||||
}
|
||||
if (curl_easy_perform(state->curl))
|
||||
goto out;
|
||||
/* CURL 7.55.0 deprecates CURLINFO_CONTENT_LENGTH_DOWNLOAD in favour of
|
||||
* the *_T version which returns a more sensible type for content length.
|
||||
*/
|
||||
#if LIBCURL_VERSION_NUM >= 0x073700
|
||||
if (curl_easy_getinfo(state->curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD_T, &cl)) {
|
||||
if (curl_easy_getinfo(state->curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &d)) {
|
||||
goto out;
|
||||
}
|
||||
#else
|
||||
if (curl_easy_getinfo(state->curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &cl)) {
|
||||
goto out;
|
||||
}
|
||||
#endif
|
||||
/* Prior CURL 7.19.4 return value of 0 could mean that the file size is not
|
||||
* know or the size is zero. From 7.19.4 CURL returns -1 if size is not
|
||||
* known and zero if it is really zero-length file. */
|
||||
#if LIBCURL_VERSION_NUM >= 0x071304
|
||||
if (cl < 0) {
|
||||
if (d < 0) {
|
||||
pstrcpy(state->errmsg, CURL_ERROR_SIZE,
|
||||
"Server didn't report file size.");
|
||||
goto out;
|
||||
}
|
||||
#else
|
||||
if (cl <= 0) {
|
||||
if (d <= 0) {
|
||||
pstrcpy(state->errmsg, CURL_ERROR_SIZE,
|
||||
"Unknown file size or zero-length file.");
|
||||
goto out;
|
||||
}
|
||||
#endif
|
||||
|
||||
s->len = cl;
|
||||
s->len = d;
|
||||
|
||||
if ((!strncasecmp(s->url, "http://", strlen("http://"))
|
||||
|| !strncasecmp(s->url, "https://", strlen("https://")))
|
||||
|
||||
+19
-2
@@ -43,10 +43,10 @@
|
||||
|
||||
#if defined(__APPLE__) && (__MACH__)
|
||||
#include <sys/ioctl.h>
|
||||
#if defined(HAVE_HOST_BLOCK_DEVICE)
|
||||
#include <paths.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/mount.h>
|
||||
#if defined(HAVE_HOST_BLOCK_DEVICE)
|
||||
#include <paths.h>
|
||||
#include <IOKit/IOKitLib.h>
|
||||
#include <IOKit/IOBSD.h>
|
||||
#include <IOKit/storage/IOMediaBSDClient.h>
|
||||
@@ -130,6 +130,14 @@
|
||||
#define RAW_LOCK_PERM_BASE 100
|
||||
#define RAW_LOCK_SHARED_BASE 200
|
||||
|
||||
/*
|
||||
* qemu_lock_fd_test always returns 0 when fd is not open for writing and
|
||||
* exclusive is true on macOS 11.3.1.
|
||||
*/
|
||||
#ifdef __APPLE__
|
||||
#define RAW_LOCK_WRITES
|
||||
#endif
|
||||
|
||||
typedef struct BDRVRawState {
|
||||
int fd;
|
||||
bool use_lock;
|
||||
@@ -673,7 +681,11 @@ static int raw_open_common(BlockDriverState *bs, QDict *options,
|
||||
false);
|
||||
|
||||
s->open_flags = open_flags;
|
||||
#ifdef RAW_LOCK_WRITES
|
||||
raw_parse_flags(bdrv_flags, &s->open_flags, s->use_lock);
|
||||
#else
|
||||
raw_parse_flags(bdrv_flags, &s->open_flags, false);
|
||||
#endif
|
||||
|
||||
s->fd = -1;
|
||||
fd = qemu_open(filename, s->open_flags, errp);
|
||||
@@ -1038,6 +1050,11 @@ static int raw_reconfigure_getfd(BlockDriverState *bs, int flags,
|
||||
bool has_writers = perm &
|
||||
(BLK_PERM_WRITE | BLK_PERM_WRITE_UNCHANGED | BLK_PERM_RESIZE);
|
||||
int fcntl_flags = O_APPEND | O_NONBLOCK;
|
||||
#ifdef RAW_LOCK_WRITES
|
||||
if (s->use_lock) {
|
||||
has_writers = true;
|
||||
}
|
||||
#endif
|
||||
#ifdef O_NOATIME
|
||||
fcntl_flags |= O_NOATIME;
|
||||
#endif
|
||||
|
||||
-13
@@ -2087,9 +2087,6 @@ static int coroutine_fn bdrv_aligned_pwritev(BdrvChild *child,
|
||||
if (bs->detect_zeroes == BLOCKDEV_DETECT_ZEROES_OPTIONS_UNMAP) {
|
||||
flags |= BDRV_REQ_MAY_UNMAP;
|
||||
}
|
||||
|
||||
/* Can't use optimization hint with bufferless zero write */
|
||||
flags &= ~BDRV_REQ_REGISTERED_BUF;
|
||||
}
|
||||
|
||||
if (ret < 0) {
|
||||
@@ -2595,16 +2592,6 @@ static int coroutine_fn bdrv_co_block_status(BlockDriverState *bs,
|
||||
ret |= (ret2 & BDRV_BLOCK_ZERO);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Now that the recursive search was done, clear the flag. Otherwise,
|
||||
* with more complicated block graphs like snapshot-access ->
|
||||
* copy-before-write -> qcow2, where the return value will be propagated
|
||||
* further up to a parent bdrv_co_do_block_status() call, both the
|
||||
* BDRV_BLOCK_RECURSE and BDRV_BLOCK_ZERO flags would be set, which is
|
||||
* not allowed.
|
||||
*/
|
||||
ret &= ~BDRV_BLOCK_RECURSE;
|
||||
}
|
||||
|
||||
out:
|
||||
|
||||
@@ -268,7 +268,6 @@ iscsi_co_generic_cb(struct iscsi_context *iscsi, int status,
|
||||
timer_mod(&iTask->retry_timer,
|
||||
qemu_clock_get_ms(QEMU_CLOCK_REALTIME) + retry_time);
|
||||
iTask->do_retry = 1;
|
||||
return;
|
||||
} else if (status == SCSI_STATUS_CHECK_CONDITION) {
|
||||
int error = iscsi_translate_sense(&task->sense);
|
||||
if (error == EAGAIN) {
|
||||
|
||||
@@ -213,17 +213,15 @@ void hmp_commit(Monitor *mon, const QDict *qdict)
|
||||
error_report("Device '%s' not found", device);
|
||||
return;
|
||||
}
|
||||
if (!blk_is_available(blk)) {
|
||||
error_report("Device '%s' has no medium", device);
|
||||
return;
|
||||
}
|
||||
|
||||
bs = bdrv_skip_implicit_filters(blk_bs(blk));
|
||||
aio_context = bdrv_get_aio_context(bs);
|
||||
aio_context_acquire(aio_context);
|
||||
|
||||
if (!blk_is_available(blk)) {
|
||||
error_report("Device '%s' has no medium", device);
|
||||
aio_context_release(aio_context);
|
||||
return;
|
||||
}
|
||||
|
||||
ret = bdrv_commit(bs);
|
||||
|
||||
aio_context_release(aio_context);
|
||||
|
||||
+3
-4
@@ -419,10 +419,9 @@ static bool nvme_process_completion(NVMeQueuePair *q)
|
||||
q->cq_phase = !q->cq_phase;
|
||||
}
|
||||
cid = le16_to_cpu(c->cid);
|
||||
if (cid == 0 || cid > NVME_NUM_REQS) {
|
||||
warn_report("NVMe: Unexpected CID in completion queue: %" PRIu32
|
||||
", should be within: 1..%u inclusively", cid,
|
||||
NVME_NUM_REQS);
|
||||
if (cid == 0 || cid > NVME_QUEUE_SIZE) {
|
||||
warn_report("NVMe: Unexpected CID in completion queue: %"PRIu32", "
|
||||
"queue size: %u", cid, NVME_QUEUE_SIZE);
|
||||
continue;
|
||||
}
|
||||
trace_nvme_complete_command(s, q->index, cid);
|
||||
|
||||
@@ -115,7 +115,7 @@ static int update_header_sync(BlockDriverState *bs)
|
||||
return bdrv_flush(bs->file->bs);
|
||||
}
|
||||
|
||||
static inline void bitmap_table_bswap_be(uint64_t *bitmap_table, size_t size)
|
||||
static inline void bitmap_table_to_be(uint64_t *bitmap_table, size_t size)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
@@ -1401,10 +1401,9 @@ static int store_bitmap(BlockDriverState *bs, Qcow2Bitmap *bm, Error **errp)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
bitmap_table_bswap_be(tb, tb_size);
|
||||
bitmap_table_to_be(tb, tb_size);
|
||||
ret = bdrv_pwrite(bs->file, tb_offset, tb_size * sizeof(tb[0]), tb, 0);
|
||||
if (ret < 0) {
|
||||
bitmap_table_bswap_be(tb, tb_size);
|
||||
error_setg_errno(errp, -ret, "Failed to write bitmap '%s' to file",
|
||||
bm_name);
|
||||
goto fail;
|
||||
|
||||
+1
-16
@@ -1614,22 +1614,7 @@ static int coroutine_fn qcow2_do_open(BlockDriverState *bs, QDict *options,
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (open_data_file && (flags & BDRV_O_NO_IO)) {
|
||||
/*
|
||||
* Don't open the data file for 'qemu-img info' so that it can be used
|
||||
* to verify that an untrusted qcow2 image doesn't refer to external
|
||||
* files.
|
||||
*
|
||||
* Note: This still makes has_data_file() return true.
|
||||
*/
|
||||
if (s->incompatible_features & QCOW2_INCOMPAT_DATA_FILE) {
|
||||
s->data_file = NULL;
|
||||
} else {
|
||||
s->data_file = bs->file;
|
||||
}
|
||||
qdict_extract_subqdict(options, NULL, "data-file.");
|
||||
qdict_del(options, "data-file");
|
||||
} else if (open_data_file) {
|
||||
if (open_data_file) {
|
||||
/* Open external data file */
|
||||
s->data_file = bdrv_open_child(NULL, options, "data-file", bs,
|
||||
&child_of_bds, BDRV_CHILD_DATA,
|
||||
|
||||
+1
-3
@@ -190,10 +190,8 @@ static BlockDriverState *bdrv_snapshot_fallback(BlockDriverState *bs)
|
||||
int bdrv_can_snapshot(BlockDriverState *bs)
|
||||
{
|
||||
BlockDriver *drv = bs->drv;
|
||||
|
||||
GLOBAL_STATE_CODE();
|
||||
|
||||
if (!drv || !bdrv_is_inserted(bs) || !bdrv_is_writable(bs)) {
|
||||
if (!drv || !bdrv_is_inserted(bs) || bdrv_is_read_only(bs)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -980,7 +980,7 @@ static int vhdx_log_write(BlockDriverState *bs, BDRVVHDXState *s,
|
||||
sector_write = merged_sector;
|
||||
} else if (i == sectors - 1 && trailing_length) {
|
||||
/* partial sector at the end of the buffer */
|
||||
ret = bdrv_pread(bs->file, file_offset + trailing_length,
|
||||
ret = bdrv_pread(bs->file, file_offset,
|
||||
VHDX_LOG_SECTOR_SIZE - trailing_length,
|
||||
merged_sector + trailing_length, 0);
|
||||
if (ret < 0) {
|
||||
|
||||
+8
-20
@@ -346,41 +346,29 @@ static int vmdk_write_cid(BlockDriverState *bs, uint32_t cid)
|
||||
BDRVVmdkState *s = bs->opaque;
|
||||
int ret = 0;
|
||||
|
||||
size_t desc_buf_size;
|
||||
|
||||
if (s->desc_offset == 0) {
|
||||
desc_buf_size = bdrv_getlength(bs->file->bs);
|
||||
if (desc_buf_size > 16ULL << 20) {
|
||||
error_report("VMDK description file too big");
|
||||
return -EFBIG;
|
||||
}
|
||||
} else {
|
||||
desc_buf_size = DESC_SIZE;
|
||||
}
|
||||
|
||||
desc = g_malloc0(desc_buf_size);
|
||||
tmp_desc = g_malloc0(desc_buf_size);
|
||||
ret = bdrv_pread(bs->file, s->desc_offset, desc_buf_size, desc, 0);
|
||||
desc = g_malloc0(DESC_SIZE);
|
||||
tmp_desc = g_malloc0(DESC_SIZE);
|
||||
ret = bdrv_pread(bs->file, s->desc_offset, DESC_SIZE, desc, 0);
|
||||
if (ret < 0) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
desc[desc_buf_size - 1] = '\0';
|
||||
desc[DESC_SIZE - 1] = '\0';
|
||||
tmp_str = strstr(desc, "parentCID");
|
||||
if (tmp_str == NULL) {
|
||||
ret = -EINVAL;
|
||||
goto out;
|
||||
}
|
||||
|
||||
pstrcpy(tmp_desc, desc_buf_size, tmp_str);
|
||||
pstrcpy(tmp_desc, DESC_SIZE, tmp_str);
|
||||
p_name = strstr(desc, "CID");
|
||||
if (p_name != NULL) {
|
||||
p_name += sizeof("CID");
|
||||
snprintf(p_name, desc_buf_size - (p_name - desc), "%" PRIx32 "\n", cid);
|
||||
pstrcat(desc, desc_buf_size, tmp_desc);
|
||||
snprintf(p_name, DESC_SIZE - (p_name - desc), "%" PRIx32 "\n", cid);
|
||||
pstrcat(desc, DESC_SIZE, tmp_desc);
|
||||
}
|
||||
|
||||
ret = bdrv_pwrite_sync(bs->file, s->desc_offset, desc_buf_size, desc, 0);
|
||||
ret = bdrv_pwrite_sync(bs->file, s->desc_offset, DESC_SIZE, desc, 0);
|
||||
|
||||
out:
|
||||
g_free(desc);
|
||||
|
||||
+4
-14
@@ -152,22 +152,12 @@ void blockdev_mark_auto_del(BlockBackend *blk)
|
||||
|
||||
JOB_LOCK_GUARD();
|
||||
|
||||
do {
|
||||
job = block_job_next_locked(NULL);
|
||||
while (job && (job->job.cancelled ||
|
||||
job->job.deferred_to_main_loop ||
|
||||
!block_job_has_bdrv(job, blk_bs(blk))))
|
||||
{
|
||||
job = block_job_next_locked(job);
|
||||
}
|
||||
if (job) {
|
||||
/*
|
||||
* This drops the job lock temporarily and polls, so we need to
|
||||
* restart processing the list from the start after this.
|
||||
*/
|
||||
for (job = block_job_next_locked(NULL); job;
|
||||
job = block_job_next_locked(job)) {
|
||||
if (block_job_has_bdrv(job, blk_bs(blk))) {
|
||||
job_cancel_locked(&job->job, false);
|
||||
}
|
||||
} while (job);
|
||||
}
|
||||
|
||||
dinfo->auto_del = 1;
|
||||
}
|
||||
|
||||
+3
-19
@@ -108,27 +108,11 @@ static void pty_chr_update_read_handler(Chardev *chr)
|
||||
static int char_pty_chr_write(Chardev *chr, const uint8_t *buf, int len)
|
||||
{
|
||||
PtyChardev *s = PTY_CHARDEV(chr);
|
||||
GPollFD pfd;
|
||||
int rc;
|
||||
|
||||
if (s->connected) {
|
||||
return io_channel_send(s->ioc, buf, len);
|
||||
if (!s->connected) {
|
||||
return len;
|
||||
}
|
||||
|
||||
/*
|
||||
* The other side might already be re-connected, but the timer might
|
||||
* not have fired yet. So let's check here whether we can write again:
|
||||
*/
|
||||
pfd.fd = QIO_CHANNEL_FILE(s->ioc)->fd;
|
||||
pfd.events = G_IO_OUT;
|
||||
pfd.revents = 0;
|
||||
TFR(rc = g_poll(&pfd, 1, 0));
|
||||
g_assert(rc >= 0);
|
||||
if (!(pfd.revents & G_IO_HUP) && (pfd.revents & G_IO_OUT)) {
|
||||
io_channel_send(s->ioc, buf, len);
|
||||
}
|
||||
|
||||
return len;
|
||||
return io_channel_send(s->ioc, buf, len);
|
||||
}
|
||||
|
||||
static GSource *pty_chr_add_watch(Chardev *chr, GIOCondition cond)
|
||||
|
||||
@@ -1065,7 +1065,6 @@ static void char_socket_finalize(Object *obj)
|
||||
qio_net_listener_set_client_func_full(s->listener, NULL, NULL,
|
||||
NULL, chr->gcontext);
|
||||
object_unref(OBJECT(s->listener));
|
||||
s->listener = NULL;
|
||||
}
|
||||
if (s->tls_creds) {
|
||||
object_unref(OBJECT(s->tls_creds));
|
||||
|
||||
@@ -41,7 +41,6 @@
|
||||
/* init terminal so that we can grab keys */
|
||||
static struct termios oldtty;
|
||||
static int old_fd0_flags;
|
||||
static int old_fd1_flags;
|
||||
static bool stdio_in_use;
|
||||
static bool stdio_allow_signal;
|
||||
static bool stdio_echo_state;
|
||||
@@ -51,8 +50,6 @@ static void term_exit(void)
|
||||
if (stdio_in_use) {
|
||||
tcsetattr(0, TCSANOW, &oldtty);
|
||||
fcntl(0, F_SETFL, old_fd0_flags);
|
||||
fcntl(1, F_SETFL, old_fd1_flags);
|
||||
stdio_in_use = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,7 +102,6 @@ static void qemu_chr_open_stdio(Chardev *chr,
|
||||
|
||||
stdio_in_use = true;
|
||||
old_fd0_flags = fcntl(0, F_GETFL);
|
||||
old_fd1_flags = fcntl(1, F_GETFL);
|
||||
tcgetattr(0, &oldtty);
|
||||
if (!g_unix_set_fd_nonblocking(0, true, NULL)) {
|
||||
error_setg_errno(errp, errno, "Failed to set FD nonblocking");
|
||||
|
||||
+1
-1
@@ -519,7 +519,7 @@ static const ChardevClass *char_get_class(const char *driver, Error **errp)
|
||||
|
||||
if (object_class_is_abstract(oc)) {
|
||||
error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "driver",
|
||||
"a non-abstract device type");
|
||||
"an abstract device type");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -290,6 +290,7 @@ meson=""
|
||||
ninja=""
|
||||
bindir="bin"
|
||||
skip_meson=no
|
||||
shared_lib="no"
|
||||
vfio_user_server="disabled"
|
||||
|
||||
# The following Meson options are handled manually (still they
|
||||
@@ -896,6 +897,12 @@ for opt do
|
||||
;;
|
||||
--enable-jemalloc) meson_option_parse --enable-malloc=jemalloc jemalloc
|
||||
;;
|
||||
--enable-shared-lib)
|
||||
shared_lib="yes"
|
||||
plugins="no"
|
||||
;;
|
||||
--disable-shared-lib) shared_lib="no"
|
||||
;;
|
||||
# everything else has the same name in configure and meson
|
||||
--*) meson_option_parse "$opt" "$optarg"
|
||||
;;
|
||||
@@ -907,6 +914,10 @@ if test "$plugins" = "yes" -a "$tcg" = "disabled"; then
|
||||
error_exit "Can't enable plugins on non-TCG builds"
|
||||
fi
|
||||
|
||||
if test "$plugins" = "yes" -a "$shared_lib" = "yes"; then
|
||||
error_exit "Can't enable plugins on shared library builds"
|
||||
fi
|
||||
|
||||
case $git_submodules_action in
|
||||
update|validate)
|
||||
if test ! -e "$source_path/.git"; then
|
||||
@@ -1031,7 +1042,7 @@ Advanced options (experts only):
|
||||
--disable-stack-protector disable compiler-provided stack protection
|
||||
--cpu=CPU Build for host CPU [$cpu]
|
||||
--with-coroutine=BACKEND coroutine backend. Supported options:
|
||||
ucontext, sigaltstack, windows
|
||||
ucontext, libucontext, sigaltstack, windows
|
||||
--enable-plugins
|
||||
enable plugins via shared library loading
|
||||
--disable-containers don't use containers for cross-building
|
||||
@@ -1595,12 +1606,26 @@ else
|
||||
error_exit "only the 'windows' coroutine backend is valid for Windows"
|
||||
fi
|
||||
;;
|
||||
libucontext)
|
||||
;;
|
||||
*)
|
||||
error_exit "unknown coroutine backend $coroutine"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
case $coroutine in
|
||||
libucontext)
|
||||
git_submodules="${git_submodules} subprojects/libucontext"
|
||||
coroutine_impl=ucontext
|
||||
libucontext="enabled"
|
||||
;;
|
||||
*)
|
||||
coroutine_impl=$coroutine
|
||||
libucontext="disabled"
|
||||
;;
|
||||
esac
|
||||
|
||||
##################################################
|
||||
# SafeStack
|
||||
|
||||
@@ -2378,7 +2403,7 @@ if [ "$bsd" = "yes" ] ; then
|
||||
echo "CONFIG_BSD=y" >> $config_host_mak
|
||||
fi
|
||||
|
||||
echo "CONFIG_COROUTINE_BACKEND=$coroutine" >> $config_host_mak
|
||||
echo "CONFIG_COROUTINE_BACKEND=$coroutine_impl" >> $config_host_mak
|
||||
|
||||
if test "$have_asan_iface_fiber" = "yes" ; then
|
||||
echo "CONFIG_ASAN_IFACE_FIBER=y" >> $config_host_mak
|
||||
@@ -2392,6 +2417,10 @@ if test "$plugins" = "yes" ; then
|
||||
echo "CONFIG_PLUGIN=y" >> $config_host_mak
|
||||
fi
|
||||
|
||||
if test "$shared_lib" = "yes" ; then
|
||||
echo "CONFIG_SHARED_LIBRARY_BUILD=y" >> $config_host_mak
|
||||
fi
|
||||
|
||||
if test -n "$gdb_bin"; then
|
||||
gdb_version=$($gdb_bin --version | head -n 1)
|
||||
if version_ge ${gdb_version##* } 9.1; then
|
||||
@@ -2416,7 +2445,7 @@ echo "QEMU_OBJCFLAGS=$QEMU_OBJCFLAGS" >> $config_host_mak
|
||||
echo "GLIB_CFLAGS=$glib_cflags" >> $config_host_mak
|
||||
echo "GLIB_LIBS=$glib_libs" >> $config_host_mak
|
||||
echo "GLIB_BINDIR=$glib_bindir" >> $config_host_mak
|
||||
echo "GLIB_VERSION=$($pkg_config --modversion glib-2.0)" >> $config_host_mak
|
||||
echo "GLIB_VERSION=$(pkg-config --modversion glib-2.0)" >> $config_host_mak
|
||||
echo "QEMU_LDFLAGS=$QEMU_LDFLAGS" >> $config_host_mak
|
||||
echo "EXESUF=$EXESUF" >> $config_host_mak
|
||||
|
||||
@@ -2558,7 +2587,11 @@ if test "$skip_meson" = no; then
|
||||
if has $sdl2_config; then
|
||||
echo "sdl2-config = [$(meson_quote $sdl2_config)]" >> $cross
|
||||
fi
|
||||
echo "strip = [$(meson_quote $strip)]" >> $cross
|
||||
if test "$shared_lib" = "yes"; then
|
||||
echo "strip = [$(meson_quote $strip), '-x']" >> $cross
|
||||
else
|
||||
echo "strip = [$(meson_quote $strip)]" >> $cross
|
||||
fi
|
||||
echo "widl = [$(meson_quote $widl)]" >> $cross
|
||||
echo "windres = [$(meson_quote $windres)]" >> $cross
|
||||
if test "$cross_compile" = "yes"; then
|
||||
|
||||
@@ -323,7 +323,7 @@ virgl_cmd_set_scanout(VuGpu *g,
|
||||
struct virtio_gpu_ctrl_command *cmd)
|
||||
{
|
||||
struct virtio_gpu_set_scanout ss;
|
||||
struct virgl_renderer_resource_info info;
|
||||
struct virgl_renderer_texture_info info;
|
||||
int ret;
|
||||
|
||||
VUGPU_FILL_CMD(ss);
|
||||
@@ -338,7 +338,7 @@ virgl_cmd_set_scanout(VuGpu *g,
|
||||
memset(&info, 0, sizeof(info));
|
||||
|
||||
if (ss.resource_id && ss.r.width && ss.r.height) {
|
||||
ret = virgl_renderer_resource_get_info(ss.resource_id, &info);
|
||||
ret = virgl_renderer_borrow_texture_for_scanout(ss.resource_id, &info);
|
||||
if (ret == -1) {
|
||||
g_critical("%s: illegal resource specified %d\n",
|
||||
__func__, ss.resource_id);
|
||||
|
||||
@@ -151,6 +151,8 @@ static void initialize_debug_host(CPUDebug *s)
|
||||
#endif
|
||||
#if defined(CONFIG_TCG_INTERPRETER)
|
||||
s->info.print_insn = print_insn_tci;
|
||||
#elif defined(CONFIG_TCG_THREADED_INTERPRETER)
|
||||
s->info.print_insn = print_insn_tcti;
|
||||
#elif defined(__i386__)
|
||||
s->info.mach = bfd_mach_i386_i386;
|
||||
s->info.cap_arch = CS_ARCH_X86;
|
||||
|
||||
+3
-66
@@ -2159,22 +2159,7 @@ static const char *csr_name(int csrno)
|
||||
case 0x0383: return "mibound";
|
||||
case 0x0384: return "mdbase";
|
||||
case 0x0385: return "mdbound";
|
||||
case 0x03a0: return "pmpcfg0";
|
||||
case 0x03a1: return "pmpcfg1";
|
||||
case 0x03a2: return "pmpcfg2";
|
||||
case 0x03a3: return "pmpcfg3";
|
||||
case 0x03a4: return "pmpcfg4";
|
||||
case 0x03a5: return "pmpcfg5";
|
||||
case 0x03a6: return "pmpcfg6";
|
||||
case 0x03a7: return "pmpcfg7";
|
||||
case 0x03a8: return "pmpcfg8";
|
||||
case 0x03a9: return "pmpcfg9";
|
||||
case 0x03aa: return "pmpcfg10";
|
||||
case 0x03ab: return "pmpcfg11";
|
||||
case 0x03ac: return "pmpcfg12";
|
||||
case 0x03ad: return "pmpcfg13";
|
||||
case 0x03ae: return "pmpcfg14";
|
||||
case 0x03af: return "pmpcfg15";
|
||||
case 0x03a0: return "pmpcfg3";
|
||||
case 0x03b0: return "pmpaddr0";
|
||||
case 0x03b1: return "pmpaddr1";
|
||||
case 0x03b2: return "pmpaddr2";
|
||||
@@ -2188,57 +2173,9 @@ static const char *csr_name(int csrno)
|
||||
case 0x03ba: return "pmpaddr10";
|
||||
case 0x03bb: return "pmpaddr11";
|
||||
case 0x03bc: return "pmpaddr12";
|
||||
case 0x03bd: return "pmpaddr13";
|
||||
case 0x03be: return "pmpaddr14";
|
||||
case 0x03bd: return "pmpaddr14";
|
||||
case 0x03be: return "pmpaddr13";
|
||||
case 0x03bf: return "pmpaddr15";
|
||||
case 0x03c0: return "pmpaddr16";
|
||||
case 0x03c1: return "pmpaddr17";
|
||||
case 0x03c2: return "pmpaddr18";
|
||||
case 0x03c3: return "pmpaddr19";
|
||||
case 0x03c4: return "pmpaddr20";
|
||||
case 0x03c5: return "pmpaddr21";
|
||||
case 0x03c6: return "pmpaddr22";
|
||||
case 0x03c7: return "pmpaddr23";
|
||||
case 0x03c8: return "pmpaddr24";
|
||||
case 0x03c9: return "pmpaddr25";
|
||||
case 0x03ca: return "pmpaddr26";
|
||||
case 0x03cb: return "pmpaddr27";
|
||||
case 0x03cc: return "pmpaddr28";
|
||||
case 0x03cd: return "pmpaddr29";
|
||||
case 0x03ce: return "pmpaddr30";
|
||||
case 0x03cf: return "pmpaddr31";
|
||||
case 0x03d0: return "pmpaddr32";
|
||||
case 0x03d1: return "pmpaddr33";
|
||||
case 0x03d2: return "pmpaddr34";
|
||||
case 0x03d3: return "pmpaddr35";
|
||||
case 0x03d4: return "pmpaddr36";
|
||||
case 0x03d5: return "pmpaddr37";
|
||||
case 0x03d6: return "pmpaddr38";
|
||||
case 0x03d7: return "pmpaddr39";
|
||||
case 0x03d8: return "pmpaddr40";
|
||||
case 0x03d9: return "pmpaddr41";
|
||||
case 0x03da: return "pmpaddr42";
|
||||
case 0x03db: return "pmpaddr43";
|
||||
case 0x03dc: return "pmpaddr44";
|
||||
case 0x03dd: return "pmpaddr45";
|
||||
case 0x03de: return "pmpaddr46";
|
||||
case 0x03df: return "pmpaddr47";
|
||||
case 0x03e0: return "pmpaddr48";
|
||||
case 0x03e1: return "pmpaddr49";
|
||||
case 0x03e2: return "pmpaddr50";
|
||||
case 0x03e3: return "pmpaddr51";
|
||||
case 0x03e4: return "pmpaddr52";
|
||||
case 0x03e5: return "pmpaddr53";
|
||||
case 0x03e6: return "pmpaddr54";
|
||||
case 0x03e7: return "pmpaddr55";
|
||||
case 0x03e8: return "pmpaddr56";
|
||||
case 0x03e9: return "pmpaddr57";
|
||||
case 0x03ea: return "pmpaddr58";
|
||||
case 0x03eb: return "pmpaddr59";
|
||||
case 0x03ec: return "pmpaddr60";
|
||||
case 0x03ed: return "pmpaddr61";
|
||||
case 0x03ee: return "pmpaddr62";
|
||||
case 0x03ef: return "pmpaddr63";
|
||||
case 0x0780: return "mtohost";
|
||||
case 0x0781: return "mfromhost";
|
||||
case 0x0782: return "mreset";
|
||||
|
||||
@@ -233,8 +233,8 @@ Use the more generic event ``DEVICE_UNPLUG_GUEST_ERROR`` instead.
|
||||
System emulator machines
|
||||
------------------------
|
||||
|
||||
Arm ``virt`` machine ``dtb-kaslr-seed`` property (since 7.1)
|
||||
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
|
||||
Arm ``virt`` machine ``dtb-kaslr-seed`` property
|
||||
''''''''''''''''''''''''''''''''''''''''''''''''
|
||||
|
||||
The ``dtb-kaslr-seed`` property on the ``virt`` board has been
|
||||
deprecated; use the new name ``dtb-randomness`` instead. The new name
|
||||
|
||||
@@ -8,4 +8,4 @@ QEMU is a trademark of Fabrice Bellard.
|
||||
QEMU is released under the `GNU General Public
|
||||
License <https://www.gnu.org/licenses/gpl-2.0.txt>`__, version 2. Parts
|
||||
of QEMU have specific licenses, see file
|
||||
`LICENSE <https://gitlab.com/qemu-project/qemu/-/raw/master/LICENSE>`__.
|
||||
`LICENSE <https://git.qemu.org/?p=qemu.git;a=blob_plain;f=LICENSE>`__.
|
||||
@@ -61,7 +61,6 @@ There are several old APIs that use the main loop AioContext:
|
||||
* LEGACY qemu_aio_set_event_notifier() - monitor an event notifier
|
||||
* LEGACY timer_new_ms() - create a timer
|
||||
* LEGACY qemu_bh_new() - create a BH
|
||||
* LEGACY qemu_bh_new_guarded() - create a BH with a device re-entrancy guard
|
||||
* LEGACY qemu_aio_wait() - run an event loop iteration
|
||||
|
||||
Since they implicitly work on the main loop they cannot be used in code that
|
||||
@@ -73,14 +72,8 @@ Instead, use the AioContext functions directly (see include/block/aio.h):
|
||||
* aio_set_event_notifier() - monitor an event notifier
|
||||
* aio_timer_new() - create a timer
|
||||
* aio_bh_new() - create a BH
|
||||
* aio_bh_new_guarded() - create a BH with a device re-entrancy guard
|
||||
* aio_poll() - run an event loop iteration
|
||||
|
||||
The qemu_bh_new_guarded/aio_bh_new_guarded APIs accept a "MemReentrancyGuard"
|
||||
argument, which is used to check for and prevent re-entrancy problems. For
|
||||
BHs associated with devices, the reentrancy-guard is contained in the
|
||||
corresponding DeviceState and named "mem_reentrancy_guard".
|
||||
|
||||
The AioContext can be obtained from the IOThread using
|
||||
iothread_get_aio_context() or for the main loop using qemu_get_aio_context().
|
||||
Code that takes an AioContext argument works both in IOThreads or the main
|
||||
|
||||
@@ -473,12 +473,6 @@ thus some extra preparation steps will be required first
|
||||
the ``libvirt-ci`` submodule to point to a commit that contains
|
||||
the ``mappings.yml`` update.
|
||||
|
||||
For enterprise distros that default to old, end-of-life versions of the
|
||||
Python runtime, QEMU uses a separate set of mappings that work with more
|
||||
recent versions. These can be found in ``tests/lcitool/mappings.yml``.
|
||||
Modifying this file should not be necessary unless the new pre-requisite
|
||||
is a Python library or tool.
|
||||
|
||||
|
||||
Adding new OS distros
|
||||
^^^^^^^^^^^^^^^^^^^^^
|
||||
@@ -996,7 +990,7 @@ class. Here's a simple usage example:
|
||||
self.vm.launch()
|
||||
res = self.vm.command('human-monitor-command',
|
||||
command_line='info version')
|
||||
self.assertRegex(res, r'^(\d+\.\d+\.\d)')
|
||||
self.assertRegexpMatches(res, r'^(\d+\.\d+\.\d)')
|
||||
|
||||
To execute your test, run:
|
||||
|
||||
@@ -1057,7 +1051,7 @@ and hypothetical example follows:
|
||||
'human-monitor-command',
|
||||
command_line='info version')
|
||||
|
||||
self.assertEqual(first_res, second_res, third_res)
|
||||
self.assertEquals(first_res, second_res, third_res)
|
||||
|
||||
At test "tear down", ``avocado_qemu.Test`` handles all the QEMUMachines
|
||||
shutdown.
|
||||
|
||||
@@ -111,9 +111,9 @@ A vring state description
|
||||
A vring address description
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
+-------+-------+------------+------+-----------+-----+
|
||||
| index | flags | descriptor | used | available | log |
|
||||
+-------+-------+------------+------+-----------+-----+
|
||||
+-------+-------+------+------------+------+-----------+-----+
|
||||
| index | flags | size | descriptor | used | available | log |
|
||||
+-------+-------+------+------------+------+-----------+-----+
|
||||
|
||||
:index: a 32-bit vring index
|
||||
|
||||
|
||||
@@ -117,13 +117,13 @@ to support the multiple thread compression migration:
|
||||
{qemu} migrate_set_capability compress on
|
||||
|
||||
3. Set the compression thread count on source:
|
||||
{qemu} migrate_set_parameter compress-threads 12
|
||||
{qemu} migrate_set_parameter compress_threads 12
|
||||
|
||||
4. Set the compression level on the source:
|
||||
{qemu} migrate_set_parameter compress-level 1
|
||||
{qemu} migrate_set_parameter compress_level 1
|
||||
|
||||
5. Set the decompression thread count on destination:
|
||||
{qemu} migrate_set_parameter decompress-threads 3
|
||||
{qemu} migrate_set_parameter decompress_threads 3
|
||||
|
||||
6. Start outgoing migration:
|
||||
{qemu} migrate -d tcp:destination.host:4444
|
||||
@@ -133,9 +133,9 @@ to support the multiple thread compression migration:
|
||||
|
||||
The following are the default settings:
|
||||
compress: off
|
||||
compress-threads: 8
|
||||
decompress-threads: 2
|
||||
compress-level: 1 (which means best speed)
|
||||
compress_threads: 8
|
||||
decompress_threads: 2
|
||||
compress_level: 1 (which means best speed)
|
||||
|
||||
So, only the first two steps are required to use the multiple
|
||||
thread compression in migration. You can do more if the default
|
||||
|
||||
+1
-1
@@ -89,7 +89,7 @@ RUNNING:
|
||||
First, set the migration speed to match your hardware's capabilities:
|
||||
|
||||
QEMU Monitor Command:
|
||||
$ migrate_set_parameter max-bandwidth 40g # or whatever is the MAX of your RDMA device
|
||||
$ migrate_set_parameter max_bandwidth 40g # or whatever is the MAX of your RDMA device
|
||||
|
||||
Next, on the destination machine, add the following to the QEMU command line:
|
||||
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
sphinx==5.3.0
|
||||
sphinx_rtd_theme==1.1.1
|
||||
@@ -1,9 +1,8 @@
|
||||
During the graphical emulation, you can use special key combinations from
|
||||
the following table to change modes. By default the modifier is Ctrl-Alt
|
||||
(used in the table below) which can be changed with ``-display`` suboption
|
||||
``mod=`` where appropriate. For example, ``-display sdl,
|
||||
grab-mod=lshift-lctrl-lalt`` changes the modifier key to Ctrl-Alt-Shift,
|
||||
while ``-display sdl,grab-mod=rctrl`` changes it to the right Ctrl key.
|
||||
During the graphical emulation, you can use special key combinations to
|
||||
change modes. The default key mappings are shown below, but if you use
|
||||
``-alt-grab`` then the modifier is Ctrl-Alt-Shift (instead of Ctrl-Alt)
|
||||
and if you use ``-ctrl-grab`` then the modifier is the right Ctrl key
|
||||
(instead of Ctrl-Alt):
|
||||
|
||||
Ctrl-Alt-f
|
||||
Toggle full screen
|
||||
@@ -29,7 +28,7 @@ Ctrl-Alt-n
|
||||
*3*
|
||||
Serial port
|
||||
|
||||
Ctrl-Alt-g
|
||||
Ctrl-Alt
|
||||
Toggle mouse and keyboard grab.
|
||||
|
||||
In the virtual consoles, you can use Ctrl-Up, Ctrl-Down, Ctrl-PageUp and
|
||||
|
||||
@@ -2,7 +2,7 @@ Multi-process QEMU
|
||||
==================
|
||||
|
||||
This document describes how to configure and use multi-process qemu.
|
||||
For the design document refer to docs/devel/multi-process.rst.
|
||||
For the design document refer to docs/devel/qemu-multiprocess.
|
||||
|
||||
1) Configuration
|
||||
----------------
|
||||
|
||||
+2
-2
@@ -1298,8 +1298,8 @@ static bool get_next_page(GuestPhysBlock **blockptr, uint64_t *pfnptr,
|
||||
|
||||
memcpy(buf + addr % page_size, hbuf, n);
|
||||
addr += n;
|
||||
if (addr % page_size == 0 || addr >= block->target_end) {
|
||||
/* we filled up the page or the current block is finished */
|
||||
if (addr % page_size == 0) {
|
||||
/* we filled up the page */
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
|
||||
+1
-1
@@ -5135,7 +5135,7 @@ float32 float32_exp2(float32 a, float_status *status)
|
||||
float64_unpack_canonical(&rp, float64_one, status);
|
||||
for (i = 0 ; i < 15 ; i++) {
|
||||
float64_unpack_canonical(&tp, float32_exp2_coefficients[i], status);
|
||||
rp = *parts_muladd(&tp, &xnp, &rp, 0, status);
|
||||
rp = *parts_muladd(&tp, &xp, &rp, 0, status);
|
||||
xnp = *parts_mul(&xnp, &xp, status);
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
#include "qemu/xattr.h"
|
||||
#include "9p-iov-marshal.h"
|
||||
#include "hw/9pfs/9p-proxy.h"
|
||||
#include "hw/9pfs/9p-util.h"
|
||||
#include "fsdev/9p-iov-marshal.h"
|
||||
|
||||
#define PROGNAME "virtfs-proxy-helper"
|
||||
@@ -339,28 +338,6 @@ static void resetugid(int suid, int sgid)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Open regular file or directory. Attempts to open any special file are
|
||||
* rejected.
|
||||
*
|
||||
* returns file descriptor or -1 on error
|
||||
*/
|
||||
static int open_regular(const char *pathname, int flags, mode_t mode)
|
||||
{
|
||||
int fd;
|
||||
|
||||
fd = open(pathname, flags, mode);
|
||||
if (fd < 0) {
|
||||
return fd;
|
||||
}
|
||||
|
||||
if (close_if_special_file(fd) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return fd;
|
||||
}
|
||||
|
||||
/*
|
||||
* send response in two parts
|
||||
* 1) ProxyHeader
|
||||
@@ -705,7 +682,7 @@ static int do_create(struct iovec *iovec)
|
||||
if (ret < 0) {
|
||||
goto unmarshal_err_out;
|
||||
}
|
||||
ret = open_regular(path.data, flags, mode);
|
||||
ret = open(path.data, flags, mode);
|
||||
if (ret < 0) {
|
||||
ret = -errno;
|
||||
}
|
||||
@@ -730,7 +707,7 @@ static int do_open(struct iovec *iovec)
|
||||
if (ret < 0) {
|
||||
goto err_out;
|
||||
}
|
||||
ret = open_regular(path.data, flags, 0);
|
||||
ret = open(path.data, flags);
|
||||
if (ret < 0) {
|
||||
ret = -errno;
|
||||
}
|
||||
|
||||
@@ -13,8 +13,6 @@
|
||||
#ifndef QEMU_9P_UTIL_H
|
||||
#define QEMU_9P_UTIL_H
|
||||
|
||||
#include "qemu/error-report.h"
|
||||
|
||||
#ifdef O_PATH
|
||||
#define O_PATH_9P_UTIL O_PATH
|
||||
#else
|
||||
@@ -114,38 +112,6 @@ static inline void close_preserve_errno(int fd)
|
||||
errno = serrno;
|
||||
}
|
||||
|
||||
/**
|
||||
* close_if_special_file() - Close @fd if neither regular file nor directory.
|
||||
*
|
||||
* @fd: file descriptor of open file
|
||||
* Return: 0 on regular file or directory, -1 otherwise
|
||||
*
|
||||
* CVE-2023-2861: Prohibit opening any special file directly on host
|
||||
* (especially device files), as a compromised client could potentially gain
|
||||
* access outside exported tree under certain, unsafe setups. We expect
|
||||
* client to handle I/O on special files exclusively on guest side.
|
||||
*/
|
||||
static inline int close_if_special_file(int fd)
|
||||
{
|
||||
struct stat stbuf;
|
||||
|
||||
if (fstat(fd, &stbuf) < 0) {
|
||||
close_preserve_errno(fd);
|
||||
return -1;
|
||||
}
|
||||
if (!S_ISREG(stbuf.st_mode) && !S_ISDIR(stbuf.st_mode)) {
|
||||
error_report_once(
|
||||
"9p: broken or compromised client detected; attempt to open "
|
||||
"special file (i.e. neither regular file, nor directory)"
|
||||
);
|
||||
close(fd);
|
||||
errno = ENXIO;
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int openat_dir(int dirfd, const char *name)
|
||||
{
|
||||
return openat(dirfd, name,
|
||||
@@ -180,10 +146,6 @@ again:
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (close_if_special_file(fd) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
serrno = errno;
|
||||
/* O_NONBLOCK was only needed to open the file. Let's drop it. We don't
|
||||
* do that with O_PATH since fcntl(F_SETFL) isn't supported, and openat()
|
||||
|
||||
@@ -48,9 +48,3 @@ v9fs_readlink(uint16_t tag, uint8_t id, int32_t fid) "tag %d id %d fid %d"
|
||||
v9fs_readlink_return(uint16_t tag, uint8_t id, char* target) "tag %d id %d name %s"
|
||||
v9fs_setattr(uint16_t tag, uint8_t id, int32_t fid, int32_t valid, int32_t mode, int32_t uid, int32_t gid, int64_t size, int64_t atime_sec, int64_t mtime_sec) "tag %u id %u fid %d iattr={valid %d mode %d uid %d gid %d size %"PRId64" atime=%"PRId64" mtime=%"PRId64" }"
|
||||
v9fs_setattr_return(uint16_t tag, uint8_t id) "tag %u id %u"
|
||||
|
||||
# xen-9p-backend.c
|
||||
xen_9pfs_alloc(char *name) "name %s"
|
||||
xen_9pfs_connect(char *name) "name %s"
|
||||
xen_9pfs_disconnect(char *name) "name %s"
|
||||
xen_9pfs_free(char *name) "name %s"
|
||||
+14
-26
@@ -24,8 +24,6 @@
|
||||
#include "qemu/option.h"
|
||||
#include "fsdev/qemu-fsdev.h"
|
||||
|
||||
#include "trace.h"
|
||||
|
||||
#define VERSIONS "1"
|
||||
#define MAX_RINGS 8
|
||||
#define MAX_RING_ORDER 9
|
||||
@@ -62,7 +60,6 @@ typedef struct Xen9pfsDev {
|
||||
|
||||
int num_rings;
|
||||
Xen9pfsRing *rings;
|
||||
MemReentrancyGuard mem_reentrancy_guard;
|
||||
} Xen9pfsDev;
|
||||
|
||||
static void xen_9pfs_disconnect(struct XenLegacyDevice *xendev);
|
||||
@@ -338,8 +335,6 @@ static void xen_9pfs_disconnect(struct XenLegacyDevice *xendev)
|
||||
Xen9pfsDev *xen_9pdev = container_of(xendev, Xen9pfsDev, xendev);
|
||||
int i;
|
||||
|
||||
trace_xen_9pfs_disconnect(xendev->name);
|
||||
|
||||
for (i = 0; i < xen_9pdev->num_rings; i++) {
|
||||
if (xen_9pdev->rings[i].evtchndev != NULL) {
|
||||
qemu_set_fd_handler(xenevtchn_fd(xen_9pdev->rings[i].evtchndev),
|
||||
@@ -348,40 +343,39 @@ static void xen_9pfs_disconnect(struct XenLegacyDevice *xendev)
|
||||
xen_9pdev->rings[i].local_port);
|
||||
xen_9pdev->rings[i].evtchndev = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int xen_9pfs_free(struct XenLegacyDevice *xendev)
|
||||
{
|
||||
Xen9pfsDev *xen_9pdev = container_of(xendev, Xen9pfsDev, xendev);
|
||||
int i;
|
||||
|
||||
if (xen_9pdev->rings[0].evtchndev != NULL) {
|
||||
xen_9pfs_disconnect(xendev);
|
||||
}
|
||||
|
||||
for (i = 0; i < xen_9pdev->num_rings; i++) {
|
||||
if (xen_9pdev->rings[i].data != NULL) {
|
||||
xen_be_unmap_grant_refs(&xen_9pdev->xendev,
|
||||
xen_9pdev->rings[i].data,
|
||||
(1 << xen_9pdev->rings[i].ring_order));
|
||||
xen_9pdev->rings[i].data = NULL;
|
||||
}
|
||||
if (xen_9pdev->rings[i].intf != NULL) {
|
||||
xen_be_unmap_grant_refs(&xen_9pdev->xendev,
|
||||
xen_9pdev->rings[i].intf,
|
||||
1);
|
||||
xen_9pdev->rings[i].intf = NULL;
|
||||
}
|
||||
if (xen_9pdev->rings[i].bh != NULL) {
|
||||
qemu_bh_delete(xen_9pdev->rings[i].bh);
|
||||
xen_9pdev->rings[i].bh = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
g_free(xen_9pdev->id);
|
||||
xen_9pdev->id = NULL;
|
||||
g_free(xen_9pdev->tag);
|
||||
xen_9pdev->tag = NULL;
|
||||
g_free(xen_9pdev->path);
|
||||
xen_9pdev->path = NULL;
|
||||
g_free(xen_9pdev->security_model);
|
||||
xen_9pdev->security_model = NULL;
|
||||
g_free(xen_9pdev->rings);
|
||||
xen_9pdev->rings = NULL;
|
||||
}
|
||||
|
||||
static int xen_9pfs_free(struct XenLegacyDevice *xendev)
|
||||
{
|
||||
trace_xen_9pfs_free(xendev->name);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -393,8 +387,6 @@ static int xen_9pfs_connect(struct XenLegacyDevice *xendev)
|
||||
V9fsState *s = &xen_9pdev->state;
|
||||
QemuOpts *fsdev;
|
||||
|
||||
trace_xen_9pfs_connect(xendev->name);
|
||||
|
||||
if (xenstore_read_fe_int(&xen_9pdev->xendev, "num-rings",
|
||||
&xen_9pdev->num_rings) == -1 ||
|
||||
xen_9pdev->num_rings > MAX_RINGS || xen_9pdev->num_rings < 1) {
|
||||
@@ -449,9 +441,7 @@ static int xen_9pfs_connect(struct XenLegacyDevice *xendev)
|
||||
xen_9pdev->rings[i].ring.out = xen_9pdev->rings[i].data +
|
||||
XEN_FLEX_RING_SIZE(ring_order);
|
||||
|
||||
xen_9pdev->rings[i].bh = qemu_bh_new_guarded(xen_9pfs_bh,
|
||||
&xen_9pdev->rings[i],
|
||||
&xen_9pdev->mem_reentrancy_guard);
|
||||
xen_9pdev->rings[i].bh = qemu_bh_new(xen_9pfs_bh, &xen_9pdev->rings[i]);
|
||||
xen_9pdev->rings[i].out_cons = 0;
|
||||
xen_9pdev->rings[i].out_size = 0;
|
||||
xen_9pdev->rings[i].inprogress = false;
|
||||
@@ -504,8 +494,6 @@ out:
|
||||
|
||||
static void xen_9pfs_alloc(struct XenLegacyDevice *xendev)
|
||||
{
|
||||
trace_xen_9pfs_alloc(xendev->name);
|
||||
|
||||
xenstore_write_be_str(xendev, "versions", VERSIONS);
|
||||
xenstore_write_be_int(xendev, "max-rings", MAX_RINGS);
|
||||
xenstore_write_be_int(xendev, "max-ring-page-order", MAX_RING_ORDER);
|
||||
|
||||
@@ -52,9 +52,6 @@ static const MemoryRegionOps AcpiCpuHotplug_ops = {
|
||||
.endianness = DEVICE_LITTLE_ENDIAN,
|
||||
.valid = {
|
||||
.min_access_size = 1,
|
||||
.max_access_size = 4,
|
||||
},
|
||||
.impl = {
|
||||
.max_access_size = 1,
|
||||
},
|
||||
};
|
||||
|
||||
@@ -947,7 +947,6 @@ static const VMStateDescription erst_vmstate = {
|
||||
|
||||
static void erst_realizefn(PCIDevice *pci_dev, Error **errp)
|
||||
{
|
||||
ERRP_GUARD();
|
||||
ERSTDeviceState *s = ACPIERST(pci_dev);
|
||||
|
||||
trace_acpi_erst_realizefn_in();
|
||||
@@ -965,15 +964,9 @@ static void erst_realizefn(PCIDevice *pci_dev, Error **errp)
|
||||
|
||||
/* HostMemoryBackend size will be multiple of PAGE_SIZE */
|
||||
s->storage_size = object_property_get_int(OBJECT(s->hostmem), "size", errp);
|
||||
if (*errp) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* Initialize backend storage and record_count */
|
||||
check_erst_backend_storage(s, errp);
|
||||
if (*errp) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* BAR 0: Programming registers */
|
||||
memory_region_init_io(&s->iomem_mr, OBJECT(pci_dev), &erst_reg_ops, s,
|
||||
@@ -984,9 +977,6 @@ static void erst_realizefn(PCIDevice *pci_dev, Error **errp)
|
||||
memory_region_init_ram(&s->exchange_mr, OBJECT(pci_dev),
|
||||
"erst.exchange",
|
||||
le32_to_cpu(s->header->record_size), errp);
|
||||
if (*errp) {
|
||||
return;
|
||||
}
|
||||
pci_register_bar(pci_dev, 1, PCI_BASE_ADDRESS_SPACE_MEMORY,
|
||||
&s->exchange_mr);
|
||||
|
||||
|
||||
+1
-5
@@ -77,7 +77,6 @@ static void build_hmat_lb(GArray *table_data, HMAT_LB_Info *hmat_lb,
|
||||
uint32_t *initiator_list)
|
||||
{
|
||||
int i, index;
|
||||
uint32_t initiator_to_index[MAX_NODES] = {};
|
||||
HMAT_LB_Data *lb_data;
|
||||
uint16_t *entry_list;
|
||||
uint32_t base;
|
||||
@@ -121,8 +120,6 @@ static void build_hmat_lb(GArray *table_data, HMAT_LB_Info *hmat_lb,
|
||||
/* Initiator Proximity Domain List */
|
||||
for (i = 0; i < num_initiator; i++) {
|
||||
build_append_int_noprefix(table_data, initiator_list[i], 4);
|
||||
/* Reverse mapping for array possitions */
|
||||
initiator_to_index[initiator_list[i]] = i;
|
||||
}
|
||||
|
||||
/* Target Proximity Domain List */
|
||||
@@ -134,8 +131,7 @@ static void build_hmat_lb(GArray *table_data, HMAT_LB_Info *hmat_lb,
|
||||
entry_list = g_new0(uint16_t, num_initiator * num_target);
|
||||
for (i = 0; i < hmat_lb->list->len; i++) {
|
||||
lb_data = &g_array_index(hmat_lb->list, HMAT_LB_Data, i);
|
||||
index = initiator_to_index[lb_data->initiator] * num_target +
|
||||
lb_data->target;
|
||||
index = lb_data->initiator * num_target + lb_data->target;
|
||||
|
||||
entry_list[index] = (uint16_t)(lb_data->data / hmat_lb->base);
|
||||
}
|
||||
|
||||
@@ -429,16 +429,6 @@ void acpi_pcihp_device_unplug_request_cb(HotplugHandler *hotplug_dev,
|
||||
* acpi_pcihp_eject_slot() when the operation is completed.
|
||||
*/
|
||||
pdev->qdev.pending_deleted_event = true;
|
||||
/* if unplug was requested before OSPM is initialized,
|
||||
* linux kernel will clear GPE0.sts[] bits during boot, which effectively
|
||||
* hides unplug event. And than followup qmp_device_del() calls remain
|
||||
* blocked by above flag permanently.
|
||||
* Unblock qmp_device_del() by setting expire limit, so user can
|
||||
* repeat unplug request later when OSPM has been booted.
|
||||
*/
|
||||
pdev->qdev.pending_deleted_expires_ms =
|
||||
qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL); /* 1 msec */
|
||||
|
||||
s->acpi_pcihp_pci_status[bsel].down |= (1U << slot);
|
||||
acpi_send_event(DEVICE(hotplug_dev), ACPI_PCI_HOTPLUG_STATUS);
|
||||
}
|
||||
|
||||
+18
-20
@@ -188,35 +188,33 @@ struct AspeedMachineState {
|
||||
static void aspeed_write_smpboot(ARMCPU *cpu,
|
||||
const struct arm_boot_info *info)
|
||||
{
|
||||
AddressSpace *as = arm_boot_address_space(cpu, info);
|
||||
static const ARMInsnFixup poll_mailbox_ready[] = {
|
||||
static const uint32_t poll_mailbox_ready[] = {
|
||||
/*
|
||||
* r2 = per-cpu go sign value
|
||||
* r1 = AST_SMP_MBOX_FIELD_ENTRY
|
||||
* r0 = AST_SMP_MBOX_FIELD_GOSIGN
|
||||
*/
|
||||
{ 0xee100fb0 }, /* mrc p15, 0, r0, c0, c0, 5 */
|
||||
{ 0xe21000ff }, /* ands r0, r0, #255 */
|
||||
{ 0xe59f201c }, /* ldr r2, [pc, #28] */
|
||||
{ 0xe1822000 }, /* orr r2, r2, r0 */
|
||||
0xee100fb0, /* mrc p15, 0, r0, c0, c0, 5 */
|
||||
0xe21000ff, /* ands r0, r0, #255 */
|
||||
0xe59f201c, /* ldr r2, [pc, #28] */
|
||||
0xe1822000, /* orr r2, r2, r0 */
|
||||
|
||||
{ 0xe59f1018 }, /* ldr r1, [pc, #24] */
|
||||
{ 0xe59f0018 }, /* ldr r0, [pc, #24] */
|
||||
0xe59f1018, /* ldr r1, [pc, #24] */
|
||||
0xe59f0018, /* ldr r0, [pc, #24] */
|
||||
|
||||
{ 0xe320f002 }, /* wfe */
|
||||
{ 0xe5904000 }, /* ldr r4, [r0] */
|
||||
{ 0xe1520004 }, /* cmp r2, r4 */
|
||||
{ 0x1afffffb }, /* bne <wfe> */
|
||||
{ 0xe591f000 }, /* ldr pc, [r1] */
|
||||
{ AST_SMP_MBOX_GOSIGN },
|
||||
{ AST_SMP_MBOX_FIELD_ENTRY },
|
||||
{ AST_SMP_MBOX_FIELD_GOSIGN },
|
||||
{ 0, FIXUP_TERMINATOR }
|
||||
0xe320f002, /* wfe */
|
||||
0xe5904000, /* ldr r4, [r0] */
|
||||
0xe1520004, /* cmp r2, r4 */
|
||||
0x1afffffb, /* bne <wfe> */
|
||||
0xe591f000, /* ldr pc, [r1] */
|
||||
AST_SMP_MBOX_GOSIGN,
|
||||
AST_SMP_MBOX_FIELD_ENTRY,
|
||||
AST_SMP_MBOX_FIELD_GOSIGN,
|
||||
};
|
||||
static const uint32_t fixupcontext[FIXUP_MAX] = { 0 };
|
||||
|
||||
arm_write_bootloader("aspeed.smpboot", as, info->smp_loader_start,
|
||||
poll_mailbox_ready, fixupcontext);
|
||||
rom_add_blob_fixed("aspeed.smpboot", poll_mailbox_ready,
|
||||
sizeof(poll_mailbox_ready),
|
||||
info->smp_loader_start);
|
||||
}
|
||||
|
||||
static void aspeed_reset_secondary(ARMCPU *cpu,
|
||||
|
||||
+28
-12
@@ -59,6 +59,26 @@ AddressSpace *arm_boot_address_space(ARMCPU *cpu,
|
||||
return cpu_get_address_space(cs, asidx);
|
||||
}
|
||||
|
||||
typedef enum {
|
||||
FIXUP_NONE = 0, /* do nothing */
|
||||
FIXUP_TERMINATOR, /* end of insns */
|
||||
FIXUP_BOARDID, /* overwrite with board ID number */
|
||||
FIXUP_BOARD_SETUP, /* overwrite with board specific setup code address */
|
||||
FIXUP_ARGPTR_LO, /* overwrite with pointer to kernel args */
|
||||
FIXUP_ARGPTR_HI, /* overwrite with pointer to kernel args (high half) */
|
||||
FIXUP_ENTRYPOINT_LO, /* overwrite with kernel entry point */
|
||||
FIXUP_ENTRYPOINT_HI, /* overwrite with kernel entry point (high half) */
|
||||
FIXUP_GIC_CPU_IF, /* overwrite with GIC CPU interface address */
|
||||
FIXUP_BOOTREG, /* overwrite with boot register address */
|
||||
FIXUP_DSB, /* overwrite with correct DSB insn for cpu */
|
||||
FIXUP_MAX,
|
||||
} FixupType;
|
||||
|
||||
typedef struct ARMInsnFixup {
|
||||
uint32_t insn;
|
||||
FixupType fixup;
|
||||
} ARMInsnFixup;
|
||||
|
||||
static const ARMInsnFixup bootloader_aarch64[] = {
|
||||
{ 0x580000c0 }, /* ldr x0, arg ; Load the lower 32-bits of DTB */
|
||||
{ 0xaa1f03e1 }, /* mov x1, xzr */
|
||||
@@ -129,10 +149,9 @@ static const ARMInsnFixup smpboot[] = {
|
||||
{ 0, FIXUP_TERMINATOR }
|
||||
};
|
||||
|
||||
void arm_write_bootloader(const char *name,
|
||||
AddressSpace *as, hwaddr addr,
|
||||
const ARMInsnFixup *insns,
|
||||
const uint32_t *fixupcontext)
|
||||
static void write_bootloader(const char *name, hwaddr addr,
|
||||
const ARMInsnFixup *insns, uint32_t *fixupcontext,
|
||||
AddressSpace *as)
|
||||
{
|
||||
/* Fix up the specified bootloader fragment and write it into
|
||||
* guest memory using rom_add_blob_fixed(). fixupcontext is
|
||||
@@ -194,8 +213,8 @@ static void default_write_secondary(ARMCPU *cpu,
|
||||
fixupcontext[FIXUP_DSB] = CP15_DSB_INSN;
|
||||
}
|
||||
|
||||
arm_write_bootloader("smpboot", as, info->smp_loader_start,
|
||||
smpboot, fixupcontext);
|
||||
write_bootloader("smpboot", info->smp_loader_start,
|
||||
smpboot, fixupcontext, as);
|
||||
}
|
||||
|
||||
void arm_write_secure_board_setup_dummy_smc(ARMCPU *cpu,
|
||||
@@ -667,10 +686,7 @@ int arm_load_dtb(hwaddr addr, const struct arm_boot_info *binfo,
|
||||
qemu_register_reset_nosnapshotload(qemu_fdt_randomize_seeds,
|
||||
rom_ptr_for_as(as, addr, size));
|
||||
|
||||
if (fdt != ms->fdt) {
|
||||
g_free(ms->fdt);
|
||||
ms->fdt = fdt;
|
||||
}
|
||||
g_free(fdt);
|
||||
|
||||
return size;
|
||||
|
||||
@@ -1155,8 +1171,8 @@ static void arm_setup_direct_kernel_boot(ARMCPU *cpu,
|
||||
fixupcontext[FIXUP_ENTRYPOINT_LO] = entry;
|
||||
fixupcontext[FIXUP_ENTRYPOINT_HI] = entry >> 32;
|
||||
|
||||
arm_write_bootloader("bootloader", as, info->loader_start,
|
||||
primary_loader, fixupcontext);
|
||||
write_bootloader("bootloader", info->loader_start,
|
||||
primary_loader, fixupcontext, as);
|
||||
|
||||
if (info->write_board_setup) {
|
||||
info->write_board_setup(cpu, info);
|
||||
|
||||
+1
-2
@@ -24,7 +24,6 @@
|
||||
#include "hw/qdev-clock.h"
|
||||
#include "hw/qdev-properties.h"
|
||||
#include "qapi/error.h"
|
||||
#include "qemu/bswap.h"
|
||||
#include "qemu/units.h"
|
||||
#include "sysemu/sysemu.h"
|
||||
|
||||
@@ -370,7 +369,7 @@ static void npcm7xx_init_fuses(NPCM7xxState *s)
|
||||
* The initial mask of disabled modules indicates the chip derivative (e.g.
|
||||
* NPCM750 or NPCM730).
|
||||
*/
|
||||
value = cpu_to_le32(nc->disabled_modules);
|
||||
value = tswap32(nc->disabled_modules);
|
||||
npcm7xx_otp_array_write(&s->fuse_array, &value, NPCM7XX_FUSE_DERIVATIVE,
|
||||
sizeof(value));
|
||||
}
|
||||
|
||||
+30
-34
@@ -16,7 +16,6 @@
|
||||
#include "qemu/units.h"
|
||||
#include "qemu/cutils.h"
|
||||
#include "qapi/error.h"
|
||||
#include "hw/arm/boot.h"
|
||||
#include "hw/arm/bcm2836.h"
|
||||
#include "hw/registerfields.h"
|
||||
#include "qemu/error-report.h"
|
||||
@@ -125,22 +124,20 @@ static const char *board_type(uint32_t board_rev)
|
||||
|
||||
static void write_smpboot(ARMCPU *cpu, const struct arm_boot_info *info)
|
||||
{
|
||||
static const ARMInsnFixup smpboot[] = {
|
||||
{ 0xe1a0e00f }, /* mov lr, pc */
|
||||
{ 0xe3a0fe00 + (BOARDSETUP_ADDR >> 4) }, /* mov pc, BOARDSETUP_ADDR */
|
||||
{ 0xee100fb0 }, /* mrc p15, 0, r0, c0, c0, 5;get core ID */
|
||||
{ 0xe7e10050 }, /* ubfx r0, r0, #0, #2 ;extract LSB */
|
||||
{ 0xe59f5014 }, /* ldr r5, =0x400000CC ;load mbox base */
|
||||
{ 0xe320f001 }, /* 1: yield */
|
||||
{ 0xe7953200 }, /* ldr r3, [r5, r0, lsl #4] ;read mbox for our core */
|
||||
{ 0xe3530000 }, /* cmp r3, #0 ;spin while zero */
|
||||
{ 0x0afffffb }, /* beq 1b */
|
||||
{ 0xe7853200 }, /* str r3, [r5, r0, lsl #4] ;clear mbox */
|
||||
{ 0xe12fff13 }, /* bx r3 ;jump to target */
|
||||
{ 0x400000cc }, /* (constant: mailbox 3 read/clear base) */
|
||||
{ 0, FIXUP_TERMINATOR }
|
||||
static const uint32_t smpboot[] = {
|
||||
0xe1a0e00f, /* mov lr, pc */
|
||||
0xe3a0fe00 + (BOARDSETUP_ADDR >> 4), /* mov pc, BOARDSETUP_ADDR */
|
||||
0xee100fb0, /* mrc p15, 0, r0, c0, c0, 5;get core ID */
|
||||
0xe7e10050, /* ubfx r0, r0, #0, #2 ;extract LSB */
|
||||
0xe59f5014, /* ldr r5, =0x400000CC ;load mbox base */
|
||||
0xe320f001, /* 1: yield */
|
||||
0xe7953200, /* ldr r3, [r5, r0, lsl #4] ;read mbox for our core*/
|
||||
0xe3530000, /* cmp r3, #0 ;spin while zero */
|
||||
0x0afffffb, /* beq 1b */
|
||||
0xe7853200, /* str r3, [r5, r0, lsl #4] ;clear mbox */
|
||||
0xe12fff13, /* bx r3 ;jump to target */
|
||||
0x400000cc, /* (constant: mailbox 3 read/clear base) */
|
||||
};
|
||||
static const uint32_t fixupcontext[FIXUP_MAX] = { 0 };
|
||||
|
||||
/* check that we don't overrun board setup vectors */
|
||||
QEMU_BUILD_BUG_ON(SMPBOOT_ADDR + sizeof(smpboot) > MVBAR_ADDR);
|
||||
@@ -148,8 +145,9 @@ static void write_smpboot(ARMCPU *cpu, const struct arm_boot_info *info)
|
||||
QEMU_BUILD_BUG_ON((BOARDSETUP_ADDR & 0xf) != 0
|
||||
|| (BOARDSETUP_ADDR >> 4) >= 0x100);
|
||||
|
||||
arm_write_bootloader("raspi_smpboot", arm_boot_address_space(cpu, info),
|
||||
info->smp_loader_start, smpboot, fixupcontext);
|
||||
rom_add_blob_fixed_as("raspi_smpboot", smpboot, sizeof(smpboot),
|
||||
info->smp_loader_start,
|
||||
arm_boot_address_space(cpu, info));
|
||||
}
|
||||
|
||||
static void write_smpboot64(ARMCPU *cpu, const struct arm_boot_info *info)
|
||||
@@ -163,28 +161,26 @@ static void write_smpboot64(ARMCPU *cpu, const struct arm_boot_info *info)
|
||||
* the primary CPU goes into the kernel. We put these variables inside
|
||||
* a rom blob, so that the reset for ROM contents zeroes them for us.
|
||||
*/
|
||||
static const ARMInsnFixup smpboot[] = {
|
||||
{ 0xd2801b05 }, /* mov x5, 0xd8 */
|
||||
{ 0xd53800a6 }, /* mrs x6, mpidr_el1 */
|
||||
{ 0x924004c6 }, /* and x6, x6, #0x3 */
|
||||
{ 0xd503205f }, /* spin: wfe */
|
||||
{ 0xf86678a4 }, /* ldr x4, [x5,x6,lsl #3] */
|
||||
{ 0xb4ffffc4 }, /* cbz x4, spin */
|
||||
{ 0xd2800000 }, /* mov x0, #0x0 */
|
||||
{ 0xd2800001 }, /* mov x1, #0x0 */
|
||||
{ 0xd2800002 }, /* mov x2, #0x0 */
|
||||
{ 0xd2800003 }, /* mov x3, #0x0 */
|
||||
{ 0xd61f0080 }, /* br x4 */
|
||||
{ 0, FIXUP_TERMINATOR }
|
||||
static const uint32_t smpboot[] = {
|
||||
0xd2801b05, /* mov x5, 0xd8 */
|
||||
0xd53800a6, /* mrs x6, mpidr_el1 */
|
||||
0x924004c6, /* and x6, x6, #0x3 */
|
||||
0xd503205f, /* spin: wfe */
|
||||
0xf86678a4, /* ldr x4, [x5,x6,lsl #3] */
|
||||
0xb4ffffc4, /* cbz x4, spin */
|
||||
0xd2800000, /* mov x0, #0x0 */
|
||||
0xd2800001, /* mov x1, #0x0 */
|
||||
0xd2800002, /* mov x2, #0x0 */
|
||||
0xd2800003, /* mov x3, #0x0 */
|
||||
0xd61f0080, /* br x4 */
|
||||
};
|
||||
static const uint32_t fixupcontext[FIXUP_MAX] = { 0 };
|
||||
|
||||
static const uint64_t spintables[] = {
|
||||
0, 0, 0, 0
|
||||
};
|
||||
|
||||
arm_write_bootloader("raspi_smpboot", as, info->smp_loader_start,
|
||||
smpboot, fixupcontext);
|
||||
rom_add_blob_fixed_as("raspi_smpboot", smpboot, sizeof(smpboot),
|
||||
info->smp_loader_start, as);
|
||||
rom_add_blob_fixed_as("raspi_spintables", spintables, sizeof(spintables),
|
||||
SPINTABLE_ADDR, as);
|
||||
}
|
||||
|
||||
@@ -193,7 +193,8 @@ static int get_pte(dma_addr_t baseaddr, uint32_t index, uint64_t *pte,
|
||||
dma_addr_t addr = baseaddr + index * sizeof(*pte);
|
||||
|
||||
/* TODO: guarantee 64-bit single-copy atomicity */
|
||||
ret = ldq_le_dma(&address_space_memory, addr, pte, MEMTXATTRS_UNSPECIFIED);
|
||||
ret = dma_memory_read(&address_space_memory, addr, pte, sizeof(*pte),
|
||||
MEMTXATTRS_UNSPECIFIED);
|
||||
|
||||
if (ret != MEMTX_OK) {
|
||||
info->type = SMMU_PTW_ERR_WALK_EABT;
|
||||
@@ -529,8 +530,6 @@ static void smmu_base_reset(DeviceState *dev)
|
||||
{
|
||||
SMMUState *s = ARM_SMMU(dev);
|
||||
|
||||
memset(s->smmu_pcibus_by_bus_num, 0, sizeof(s->smmu_pcibus_by_bus_num));
|
||||
|
||||
g_hash_table_remove_all(s->configs);
|
||||
g_hash_table_remove_all(s->iotlb);
|
||||
}
|
||||
|
||||
+8
-31
@@ -98,34 +98,20 @@ static void smmuv3_write_gerrorn(SMMUv3State *s, uint32_t new_gerrorn)
|
||||
trace_smmuv3_write_gerrorn(toggled & pending, s->gerrorn);
|
||||
}
|
||||
|
||||
static inline MemTxResult queue_read(SMMUQueue *q, Cmd *cmd)
|
||||
static inline MemTxResult queue_read(SMMUQueue *q, void *data)
|
||||
{
|
||||
dma_addr_t addr = Q_CONS_ENTRY(q);
|
||||
MemTxResult ret;
|
||||
int i;
|
||||
|
||||
ret = dma_memory_read(&address_space_memory, addr, cmd, sizeof(Cmd),
|
||||
MEMTXATTRS_UNSPECIFIED);
|
||||
if (ret != MEMTX_OK) {
|
||||
return ret;
|
||||
}
|
||||
for (i = 0; i < ARRAY_SIZE(cmd->word); i++) {
|
||||
le32_to_cpus(&cmd->word[i]);
|
||||
}
|
||||
return ret;
|
||||
return dma_memory_read(&address_space_memory, addr, data, q->entry_size,
|
||||
MEMTXATTRS_UNSPECIFIED);
|
||||
}
|
||||
|
||||
static MemTxResult queue_write(SMMUQueue *q, Evt *evt_in)
|
||||
static MemTxResult queue_write(SMMUQueue *q, void *data)
|
||||
{
|
||||
dma_addr_t addr = Q_PROD_ENTRY(q);
|
||||
MemTxResult ret;
|
||||
Evt evt = *evt_in;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(evt.word); i++) {
|
||||
cpu_to_le32s(&evt.word[i]);
|
||||
}
|
||||
ret = dma_memory_write(&address_space_memory, addr, &evt, sizeof(Evt),
|
||||
ret = dma_memory_write(&address_space_memory, addr, data, q->entry_size,
|
||||
MEMTXATTRS_UNSPECIFIED);
|
||||
if (ret != MEMTX_OK) {
|
||||
return ret;
|
||||
@@ -304,7 +290,7 @@ static void smmuv3_init_regs(SMMUv3State *s)
|
||||
static int smmu_get_ste(SMMUv3State *s, dma_addr_t addr, STE *buf,
|
||||
SMMUEventInfo *event)
|
||||
{
|
||||
int ret, i;
|
||||
int ret;
|
||||
|
||||
trace_smmuv3_get_ste(addr);
|
||||
/* TODO: guarantee 64-bit single-copy atomicity */
|
||||
@@ -317,9 +303,6 @@ static int smmu_get_ste(SMMUv3State *s, dma_addr_t addr, STE *buf,
|
||||
event->u.f_ste_fetch.addr = addr;
|
||||
return -EINVAL;
|
||||
}
|
||||
for (i = 0; i < ARRAY_SIZE(buf->word); i++) {
|
||||
le32_to_cpus(&buf->word[i]);
|
||||
}
|
||||
return 0;
|
||||
|
||||
}
|
||||
@@ -329,7 +312,7 @@ static int smmu_get_cd(SMMUv3State *s, STE *ste, uint32_t ssid,
|
||||
CD *buf, SMMUEventInfo *event)
|
||||
{
|
||||
dma_addr_t addr = STE_CTXPTR(ste);
|
||||
int ret, i;
|
||||
int ret;
|
||||
|
||||
trace_smmuv3_get_cd(addr);
|
||||
/* TODO: guarantee 64-bit single-copy atomicity */
|
||||
@@ -342,9 +325,6 @@ static int smmu_get_cd(SMMUv3State *s, STE *ste, uint32_t ssid,
|
||||
event->u.f_ste_fetch.addr = addr;
|
||||
return -EINVAL;
|
||||
}
|
||||
for (i = 0; i < ARRAY_SIZE(buf->word); i++) {
|
||||
le32_to_cpus(&buf->word[i]);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -426,7 +406,7 @@ static int smmu_find_ste(SMMUv3State *s, uint32_t sid, STE *ste,
|
||||
return -EINVAL;
|
||||
}
|
||||
if (s->features & SMMU_FEATURE_2LVL_STE) {
|
||||
int l1_ste_offset, l2_ste_offset, max_l2_ste, span, i;
|
||||
int l1_ste_offset, l2_ste_offset, max_l2_ste, span;
|
||||
dma_addr_t l1ptr, l2ptr;
|
||||
STEDesc l1std;
|
||||
|
||||
@@ -450,9 +430,6 @@ static int smmu_find_ste(SMMUv3State *s, uint32_t sid, STE *ste,
|
||||
event->u.f_ste_fetch.addr = l1ptr;
|
||||
return -EINVAL;
|
||||
}
|
||||
for (i = 0; i < ARRAY_SIZE(l1std.word); i++) {
|
||||
le32_to_cpus(&l1std.word[i]);
|
||||
}
|
||||
|
||||
span = L1STD_SPAN(&l1std);
|
||||
|
||||
|
||||
@@ -1713,7 +1713,11 @@ static void virt_set_memmap(VirtMachineState *vms, int pa_bits)
|
||||
* irrespective of the underlying capabilities of the HW.
|
||||
*/
|
||||
if (!vms->highmem) {
|
||||
#ifdef CONFIG_DARWIN
|
||||
pa_bits = 36;
|
||||
#else
|
||||
pa_bits = 32;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -213,7 +213,7 @@ static void xlnx_zynqmp_create_rpu(MachineState *ms, XlnxZynqMPState *s,
|
||||
const char *boot_cpu, Error **errp)
|
||||
{
|
||||
int i;
|
||||
int num_rpus = MIN((int)(ms->smp.cpus - XLNX_ZYNQMP_NUM_APU_CPUS),
|
||||
int num_rpus = MIN(ms->smp.cpus - XLNX_ZYNQMP_NUM_APU_CPUS,
|
||||
XLNX_ZYNQMP_NUM_RPU_CPUS);
|
||||
|
||||
if (num_rpus <= 0) {
|
||||
|
||||
@@ -47,3 +47,6 @@ config PL041
|
||||
|
||||
config CS4231
|
||||
bool
|
||||
|
||||
config SCREAMER
|
||||
bool
|
||||
+1
-1
@@ -503,7 +503,7 @@ static void es1370_write(void *opaque, hwaddr addr, uint64_t val, unsigned size)
|
||||
case ES1370_REG_DAC2_SCOUNT:
|
||||
case ES1370_REG_ADC_SCOUNT:
|
||||
d += (addr - ES1370_REG_DAC1_SCOUNT) >> 2;
|
||||
d->scount = (val & 0xffff) << 16 | (val & 0xffff);
|
||||
d->scount = (val & 0xffff) | (d->scount & ~0xffff);
|
||||
ldebug ("chan %td CURR_SAMP_CT %d, SAMP_CT %d\n",
|
||||
d - &s->chan[0], val >> 16, (val & 0xffff));
|
||||
break;
|
||||
|
||||
+8
-21
@@ -22,7 +22,6 @@
|
||||
#include "hw/qdev-properties.h"
|
||||
#include "intel-hda.h"
|
||||
#include "migration/vmstate.h"
|
||||
#include "qemu/host-utils.h"
|
||||
#include "qemu/module.h"
|
||||
#include "intel-hda-defs.h"
|
||||
#include "audio/audio.h"
|
||||
@@ -191,9 +190,9 @@ struct HDAAudioState {
|
||||
bool use_timer;
|
||||
};
|
||||
|
||||
static inline uint32_t hda_bytes_per_second(HDAAudioStream *st)
|
||||
static inline int64_t hda_bytes_per_second(HDAAudioStream *st)
|
||||
{
|
||||
return 2 * (uint32_t)st->as.nchannels * (uint32_t)st->as.freq;
|
||||
return 2LL * st->as.nchannels * st->as.freq;
|
||||
}
|
||||
|
||||
static inline void hda_timer_sync_adjust(HDAAudioStream *st, int64_t target_pos)
|
||||
@@ -224,18 +223,12 @@ static void hda_audio_input_timer(void *opaque)
|
||||
|
||||
int64_t now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
|
||||
|
||||
int64_t uptime = now - st->buft_start;
|
||||
int64_t buft_start = st->buft_start;
|
||||
int64_t wpos = st->wpos;
|
||||
int64_t rpos = st->rpos;
|
||||
int64_t wanted_rpos;
|
||||
|
||||
if (uptime <= 0) {
|
||||
/* wanted_rpos <= 0 */
|
||||
goto out_timer;
|
||||
}
|
||||
|
||||
wanted_rpos = muldiv64(uptime, hda_bytes_per_second(st),
|
||||
NANOSECONDS_PER_SECOND);
|
||||
int64_t wanted_rpos = hda_bytes_per_second(st) * (now - buft_start)
|
||||
/ NANOSECONDS_PER_SECOND;
|
||||
wanted_rpos &= -4; /* IMPORTANT! clip to frames */
|
||||
|
||||
if (wanted_rpos <= rpos) {
|
||||
@@ -294,18 +287,12 @@ static void hda_audio_output_timer(void *opaque)
|
||||
|
||||
int64_t now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
|
||||
|
||||
int64_t uptime = now - st->buft_start;
|
||||
int64_t buft_start = st->buft_start;
|
||||
int64_t wpos = st->wpos;
|
||||
int64_t rpos = st->rpos;
|
||||
int64_t wanted_wpos;
|
||||
|
||||
if (uptime <= 0) {
|
||||
/* wanted_wpos <= 0 */
|
||||
goto out_timer;
|
||||
}
|
||||
|
||||
wanted_wpos = muldiv64(uptime, hda_bytes_per_second(st),
|
||||
NANOSECONDS_PER_SECOND);
|
||||
int64_t wanted_wpos = hda_bytes_per_second(st) * (now - buft_start)
|
||||
/ NANOSECONDS_PER_SECOND;
|
||||
wanted_wpos &= -4; /* IMPORTANT! clip to frames */
|
||||
|
||||
if (wanted_wpos <= wpos) {
|
||||
|
||||
@@ -12,3 +12,4 @@ softmmu_ss.add(when: 'CONFIG_PL041', if_true: files('pl041.c', 'lm4549.c'))
|
||||
softmmu_ss.add(when: 'CONFIG_SB16', if_true: files('sb16.c'))
|
||||
softmmu_ss.add(when: 'CONFIG_VT82C686', if_true: files('via-ac97.c'))
|
||||
softmmu_ss.add(when: 'CONFIG_WM8750', if_true: files('wm8750.c'))
|
||||
softmmu_ss.add(when: 'CONFIG_SCREAMER', if_true: files('screamer.c'))
|
||||
@@ -0,0 +1,986 @@
|
||||
/*
|
||||
* File: Screamer.c
|
||||
* Description: Implement the Screamer sound chip used in Apple Macintoshes.
|
||||
* It works by filling a buffer, then playing the buffer.
|
||||
*/
|
||||
|
||||
#include "qemu/osdep.h"
|
||||
#include "audio/audio.h"
|
||||
#include "hw/hw.h"
|
||||
#include "hw/irq.h"
|
||||
#include <inttypes.h>
|
||||
#include "hw/ppc/mac_dbdma.h"
|
||||
#include "hw/qdev-properties.h"
|
||||
#include "migration/vmstate.h"
|
||||
#include "include/hw/audio/screamer.h"
|
||||
|
||||
#define DEBUG_SCREAMER 0
|
||||
#define DPRINTF(fmt, ...) \
|
||||
do { if (DEBUG_SCREAMER) { printf(fmt , ## __VA_ARGS__); } } while (0)
|
||||
|
||||
#define SOUND_CONTROL_REG 0
|
||||
#define CODEC_CONTROL_REG 1
|
||||
#define CODEC_STATUS_REG 2
|
||||
#define CLIP_COUNT_REG 3
|
||||
#define BYTE_SWAP_REG 4
|
||||
#define FRAME_COUNT_REG 5
|
||||
|
||||
#define AWACS_BUSY 0x01000000
|
||||
|
||||
/* Used with AWACS register 1 */
|
||||
#define RECALIBRATE 0x004
|
||||
#define LOOPTHRU 0x040
|
||||
#define SPEAKER_MUTE 0x080
|
||||
#define HEADPHONE_MUTE 0x200
|
||||
#define OUTPUT_ZERO 0x400
|
||||
#define OUTPUT_ONE 0x800
|
||||
#define PARALLEL_OUTPUT 0xc00
|
||||
|
||||
/* Function prototypes */
|
||||
static uint32_t set_busy_bit(uint32_t value, int bit);
|
||||
static uint32_t set_part_ready_bit(uint32_t value, int bit_value);
|
||||
static uint32_t set_revision(uint32_t input_value);
|
||||
static uint32_t set_manufacturer(uint32_t input_value);
|
||||
static int get_sampling_rate(ScreamerState *s);
|
||||
static uint32_t get_frame_count_reg(ScreamerState *s);
|
||||
static void add_to_speaker_buffer(DBDMA_io *io);
|
||||
static void dma_request(DBDMA_io *io);
|
||||
|
||||
|
||||
/**************************** Getters *************************/
|
||||
|
||||
/* Returns the codec control register's encoded AWACS address */
|
||||
static uint8_t get_codec_control_address(uint32_t value)
|
||||
{
|
||||
uint8_t return_value;
|
||||
return_value = (value >> 12) & 0x00000fff;
|
||||
return return_value;
|
||||
}
|
||||
|
||||
|
||||
static uint32_t get_sound_control_reg(ScreamerState *s)
|
||||
{
|
||||
DPRINTF("%s() called - returned 0x%x\n", __func__, s->sound_control);
|
||||
return s->sound_control;
|
||||
}
|
||||
|
||||
/* The AWACS registers are accessed thru this register */
|
||||
static uint32_t get_codec_control_reg(ScreamerState *s)
|
||||
{
|
||||
int awacs_register = get_codec_control_address(s->codec_control);
|
||||
uint32_t return_value = s->awacs[awacs_register];
|
||||
return_value = set_busy_bit(return_value, 0); /* Tell CPU we are ready */
|
||||
DPRINTF("%s() called - returned 0x%x\tAWACS register: %d\n", __func__,
|
||||
return_value, awacs_register);
|
||||
return return_value;
|
||||
}
|
||||
|
||||
/*
|
||||
* Determines if the readback bit is set.
|
||||
* It is used by the Codec Control register.
|
||||
*/
|
||||
static bool readback_enabled(ScreamerState *s)
|
||||
{
|
||||
/* Note: bit zero is the readback enabled bit */
|
||||
if (s->awacs[7] & 1) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
static uint32_t get_codec_status_reg(ScreamerState *s)
|
||||
{
|
||||
uint32_t return_value;
|
||||
|
||||
/* if in readback mode - return AWACS register value */
|
||||
if (readback_enabled(s)) {
|
||||
int awacs_register = (s->awacs[7] & 0xe) >> 1;
|
||||
s->awacs[7] = s->awacs[7] & 0xfffffffe; /* turn off readback mode */
|
||||
return_value = s->awacs[awacs_register] << 4;
|
||||
DPRINTF("readback enable bit is set, returning AWACS register %d\t"
|
||||
"value:0x%x\n", awacs_register, return_value);
|
||||
|
||||
return return_value;
|
||||
}
|
||||
|
||||
/* Tell CPU we are ready */
|
||||
return_value = set_part_ready_bit(s->codec_status, 1);
|
||||
|
||||
/* Set Revision to Screamer */
|
||||
return_value = set_revision(return_value);
|
||||
|
||||
/* Set the Manufacturer to Crystal */
|
||||
return_value = set_manufacturer(return_value);
|
||||
DPRINTF("%s() called - returned 0x%x\n", __func__, return_value);
|
||||
|
||||
return return_value;
|
||||
}
|
||||
|
||||
static uint32_t get_clip_count_reg(ScreamerState *s)
|
||||
{
|
||||
DPRINTF("%s() called - returned 0x%x\n", __func__, s->clip_count);
|
||||
uint32_t return_value;
|
||||
return_value = s->clip_count;
|
||||
/* This is reset everytime it is read */
|
||||
s->clip_count = 0;
|
||||
return return_value;
|
||||
}
|
||||
|
||||
static uint32_t get_byte_swap_reg(ScreamerState *s)
|
||||
{
|
||||
DPRINTF("%s() called - returned 0x%x\n", __func__, s->byte_swap);
|
||||
/*
|
||||
* If all you hear is noise, it could be this register reporting the
|
||||
* wrong value.
|
||||
*/
|
||||
return s->byte_swap ? 0 : 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns the frame (sample) count
|
||||
*/
|
||||
static uint32_t get_frame_count_reg(ScreamerState *s)
|
||||
{
|
||||
DPRINTF("%s() called - returned 0x%x\n", __func__, s->frame_count);
|
||||
return s->frame_count;
|
||||
}
|
||||
|
||||
static uint8_t get_left_vol(uint32_t value)
|
||||
{
|
||||
return value & 0xf;
|
||||
}
|
||||
|
||||
static uint8_t get_right_vol(uint32_t value)
|
||||
{
|
||||
return value & 0x3c0 >> 6;
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns the sampling rate.
|
||||
* If the audio is playing back too fast or too slow, this function may be the
|
||||
* cause.
|
||||
*/
|
||||
static int get_sampling_rate(ScreamerState *s)
|
||||
{
|
||||
uint32_t screamer_rate = s->sound_control & 0x700;
|
||||
int return_value;
|
||||
|
||||
/* All return values are in Hertz */
|
||||
switch (screamer_rate) {
|
||||
case 0x0:
|
||||
return_value = 44100;
|
||||
break;
|
||||
case 0x100:
|
||||
return_value = 29400;
|
||||
break;
|
||||
case 0x200:
|
||||
return_value = 22050;
|
||||
break;
|
||||
case 0x300:
|
||||
return_value = 17640;
|
||||
break;
|
||||
case 0x400:
|
||||
return_value = 14700;
|
||||
break;
|
||||
case 0x500:
|
||||
return_value = 11025;
|
||||
break;
|
||||
case 0x600:
|
||||
return_value = 8820;
|
||||
break;
|
||||
case 0x700:
|
||||
return_value = 7350;
|
||||
break;
|
||||
default:
|
||||
DPRINTF("get_sampling_rate() unknown value: 0x%x\nDefaulting to"
|
||||
" 44100 Hz.\n", screamer_rate);
|
||||
return 44100;
|
||||
}
|
||||
DPRINTF("%s() called - returning %dHz\n", __func__, return_value);
|
||||
return return_value;
|
||||
}
|
||||
|
||||
/**************************** End of getters *************************/
|
||||
|
||||
/***************************** Speaker call back *************************/
|
||||
|
||||
/* resets the play and buffer position markers */
|
||||
static void reset_markers(ScreamerState *s)
|
||||
{
|
||||
s->spk_play_position = 0;
|
||||
s->spk_buffer_position = 0;
|
||||
}
|
||||
|
||||
|
||||
/* Sends the samples to the host for playing */
|
||||
static void send_samples_to_host(ScreamerState *s, int max_samples)
|
||||
{
|
||||
int write_length, requested_length;
|
||||
requested_length = MIN(max_samples, (s->spk_buffer_position -
|
||||
s->spk_play_position));
|
||||
write_length = AUD_write(s->speaker_voice,
|
||||
&s->spk_buffer[s->spk_play_position],
|
||||
requested_length);
|
||||
DPRINTF("requested length: %d\twrite length: %d\t",
|
||||
requested_length, write_length);
|
||||
s->spk_play_position += write_length;
|
||||
DPRINTF("AUD_write %d/%d\n", s->spk_play_position, s->spk_buffer_position);
|
||||
s->frame_count += write_length;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Called by QEMU's audio system to tell the output backend to send samples
|
||||
* from the buffer to the host sound system.
|
||||
* opaque: a pointer to the ScreamerState instance.
|
||||
* max_samples: the number of samples that can be sent to the hardware buffer.
|
||||
*/
|
||||
static void speaker_callback(void *opaque, int max_samples)
|
||||
{
|
||||
ScreamerState *s = (ScreamerState *) opaque;
|
||||
|
||||
/* if we have more samples to play */
|
||||
if (s->spk_buffer_position > 0) {
|
||||
if (s->spk_buffer_position > s->spk_play_position) {
|
||||
DPRINTF("%s() called - max_samples: %d\n", __func__, max_samples);
|
||||
send_samples_to_host(s, max_samples);
|
||||
}
|
||||
if (s->spk_play_position >= s->spk_buffer_position) {
|
||||
DPRINTF("done playing buffer\n");
|
||||
DPRINTF("pp: %d\tbp: %d\n", s->spk_play_position,
|
||||
s->spk_buffer_position);
|
||||
if (s->spk_play_position > s->spk_buffer_position) {
|
||||
DPRINTF("Error detected! - pp > bp\n\a");
|
||||
}
|
||||
reset_markers(s);
|
||||
/* play postponed samples */
|
||||
if (s->dma_io.len > 0) {
|
||||
DPRINTF("playing postponed samples\n");
|
||||
add_to_speaker_buffer(&s->dma_io);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/************************* End of speaker call back *************************/
|
||||
|
||||
|
||||
/* Opens the speaker's voice */
|
||||
static void open_speaker_voice(ScreamerState *s)
|
||||
{
|
||||
DPRINTF("%s() called\n", __func__);
|
||||
|
||||
/* if voice is already open return from function */
|
||||
if (s->speaker_voice != NULL) {
|
||||
DPRINTF("closing speaker voice\n");
|
||||
AUD_close_out(&s->card, s->speaker_voice);
|
||||
s->speaker_voice = NULL;
|
||||
}
|
||||
struct audsettings audio_settings;
|
||||
audio_settings.freq = get_sampling_rate(s); /* in hertz */
|
||||
audio_settings.nchannels = 2; /* stereo output */
|
||||
audio_settings.fmt = AUDIO_FORMAT_S16; /* signed 16 bit */
|
||||
audio_settings.endianness = get_byte_swap_reg(s); /* endianness */
|
||||
s->speaker_voice = AUD_open_out(&s->card, s->speaker_voice, SOUND_CHIP_NAME
|
||||
" speaker", s, speaker_callback,
|
||||
&audio_settings);
|
||||
if (!s->speaker_voice) {
|
||||
AUD_log(SOUND_CHIP_NAME, "Out voice could not be opened\n");
|
||||
} else {
|
||||
AUD_set_active_out(s->speaker_voice, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/******************************* Setters *************************************/
|
||||
|
||||
|
||||
/* Updates QEMU's audio backend settings */
|
||||
static void set_QEMU_audio_settings(ScreamerState *s)
|
||||
{
|
||||
DPRINTF("%s() called\n", __func__);
|
||||
open_speaker_voice(s);
|
||||
}
|
||||
|
||||
|
||||
/* Return value: 1 = muted 0 = not muted */
|
||||
static int is_muted(ScreamerState *s)
|
||||
{
|
||||
int mute_state = s->awacs[1] & SPEAKER_MUTE ? 1 : 0;
|
||||
if (s->awacs[1] & SPEAKER_MUTE) {
|
||||
DPRINTF("speaker is muted\n");
|
||||
} else {
|
||||
DPRINTF("speaker is unmuted\n");
|
||||
}
|
||||
|
||||
if (s->awacs[1] & HEADPHONE_MUTE) {
|
||||
DPRINTF("headphone is muted\n");
|
||||
} else {
|
||||
DPRINTF("headphone is unmuted\n");
|
||||
}
|
||||
return mute_state;
|
||||
}
|
||||
|
||||
|
||||
/* Converts Screamer's volume system to QEMU's system */
|
||||
static int screamer_to_qemu_volume(int x)
|
||||
{
|
||||
return -16 * x + 240;
|
||||
}
|
||||
|
||||
|
||||
/* Sets QEMU's volume. */
|
||||
static void set_volume(ScreamerState *s)
|
||||
{
|
||||
int should_mute = is_muted(s);
|
||||
|
||||
/* Get Screamer volume values */
|
||||
uint8_t left_vol = get_left_vol(s->awacs[4]);
|
||||
uint8_t right_vol = get_right_vol(s->awacs[4]);
|
||||
DPRINTF("set_volume() called - M:%d\tL:%d\tR:%d\n", should_mute, left_vol,
|
||||
right_vol);
|
||||
|
||||
/* Convert Screamer to QEMU volume values */
|
||||
left_vol = screamer_to_qemu_volume(left_vol);
|
||||
right_vol = screamer_to_qemu_volume(right_vol);
|
||||
DPRINTF("QEMU volume: L:%d\tR:%d\n", left_vol, right_vol);
|
||||
AUD_set_volume_out(s->speaker_voice, should_mute, left_vol, right_vol);
|
||||
}
|
||||
|
||||
|
||||
/* Sets the sound control register */
|
||||
static void set_sound_control_reg(ScreamerState *s, uint32_t value)
|
||||
{
|
||||
DPRINTF("set_sound_control_reg() called - value: 0x%x\n", value);
|
||||
s->sound_control = value;
|
||||
set_QEMU_audio_settings(s);
|
||||
}
|
||||
|
||||
|
||||
/* Used for input gain only - can be ignored for now. */
|
||||
static void set_awacs_0_reg(ScreamerState *s, uint32_t new_value)
|
||||
{
|
||||
DPRINTF("Settings AWACS register 0 to 0x%x\n", s->awacs[0]);
|
||||
s->awacs[0] = new_value;
|
||||
}
|
||||
|
||||
|
||||
static void set_awacs_1_reg(ScreamerState *s, uint32_t new_value)
|
||||
{
|
||||
DPRINTF("Settings AWACS register 1 to 0x%x\n", new_value);
|
||||
|
||||
s->awacs[1] = new_value;
|
||||
|
||||
/* If recalibration requested */
|
||||
if (new_value & RECALIBRATE) {
|
||||
DPRINTF("Recalibration requested - unimplemented\n");
|
||||
new_value = new_value ^ RECALIBRATE; /* Turn off recalibrate bit */
|
||||
}
|
||||
|
||||
/* If loop thru set - what does this mean? */
|
||||
if (new_value & LOOPTHRU) {
|
||||
DPRINTF("Loopthru enabled - doing nothing\n");
|
||||
}
|
||||
|
||||
/* Set headphone jack mute state */
|
||||
if (new_value & HEADPHONE_MUTE) {
|
||||
DPRINTF("Headphone muted\n");
|
||||
}
|
||||
|
||||
else {
|
||||
DPRINTF("Headphone unmuted\n");
|
||||
}
|
||||
|
||||
if (new_value & SPEAKER_MUTE) {
|
||||
DPRINTF("Speaker muted\n");
|
||||
}
|
||||
|
||||
else {
|
||||
DPRINTF("Speaker unmuted\n");
|
||||
}
|
||||
|
||||
if (new_value & OUTPUT_ZERO) {
|
||||
DPRINTF("output zero set - not sure what this means\n");
|
||||
}
|
||||
|
||||
if (new_value & OUTPUT_ONE) {
|
||||
DPRINTF("output one set - not sure what this means\n");
|
||||
}
|
||||
|
||||
if (new_value & PARALLEL_OUTPUT) {
|
||||
DPRINTF("parallel port enabled - but no parallel port here\n");
|
||||
}
|
||||
|
||||
set_volume(s);
|
||||
}
|
||||
|
||||
|
||||
/* This is used for headphone volume - not needed */
|
||||
static void set_awacs_2_reg(ScreamerState *s, uint32_t new_value)
|
||||
{
|
||||
DPRINTF("Settings AWACS register 2 to 0x%x\n"
|
||||
"Ignoring change in headphone volume.\n", s->awacs[2]);
|
||||
s->awacs[2] = new_value;
|
||||
}
|
||||
|
||||
|
||||
/* Unknown register purpose */
|
||||
static void set_awacs_3_reg(ScreamerState *s, uint32_t new_value)
|
||||
{
|
||||
DPRINTF("Settings AWACS register 3 to 0x%x\n"
|
||||
"This register has an unknown purpose and does not do anything\n",
|
||||
s->awacs[3]);
|
||||
s->awacs[3] = new_value;
|
||||
}
|
||||
|
||||
|
||||
/* Mostly deals with speaker volume */
|
||||
static void set_awacs_4_reg(ScreamerState *s, uint32_t new_value)
|
||||
{
|
||||
DPRINTF("AWACS register 4 write: 0x%x\n", new_value);
|
||||
s->awacs[4] = new_value;
|
||||
set_volume(s);
|
||||
}
|
||||
|
||||
|
||||
/* This register is about loop thru stuff I don't understand */
|
||||
static void set_awacs_5_reg(ScreamerState *s, uint32_t new_value)
|
||||
{
|
||||
DPRINTF("Settings AWACS register 5 to 0x%x\n"
|
||||
"Loop thru update ignored.\n", s->awacs[5]);
|
||||
s->awacs[5] = new_value;
|
||||
}
|
||||
|
||||
|
||||
/* Prints the states of the AWACS power register */
|
||||
static void print_power_reg_values(uint32_t value)
|
||||
{
|
||||
if ((value & 0x3) == 0) {
|
||||
printf("Screamer run state set\n");
|
||||
}
|
||||
if ((value & 0x3) == 1) {
|
||||
printf("Screamer doze state set\n");
|
||||
}
|
||||
if ((value & 0x3) == 2) {
|
||||
printf("Screamer idle state set\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Power Magement register */
|
||||
static void set_awacs_6_reg(ScreamerState *s, uint32_t new_value)
|
||||
{
|
||||
DPRINTF("Settings AWACS register 6 to 0x%x\n"
|
||||
"Power management update ignored.\n", s->awacs[6]);
|
||||
if (DEBUG_SCREAMER) {
|
||||
print_power_reg_values(new_value);
|
||||
}
|
||||
s->awacs[6] = new_value;
|
||||
}
|
||||
|
||||
|
||||
/* Read Back - repeating something that was sent to this chip? */
|
||||
static void set_awacs_7_reg(ScreamerState *s, uint32_t new_value)
|
||||
{
|
||||
DPRINTF("Settings AWACS register 7 to 0x%x\n", new_value);
|
||||
s->awacs[7] = new_value;
|
||||
}
|
||||
|
||||
|
||||
/* Sets the AWACs registers - a.k.a. shadow registers */
|
||||
static void set_awacs_register(ScreamerState *s, uint32_t value)
|
||||
{
|
||||
int the_register = get_codec_control_address(value);
|
||||
|
||||
switch (the_register) {
|
||||
case 0:
|
||||
set_awacs_0_reg(s, value);
|
||||
break;
|
||||
case 1:
|
||||
set_awacs_1_reg(s, value);
|
||||
break;
|
||||
case 2:
|
||||
set_awacs_2_reg(s, value);
|
||||
break;
|
||||
case 3:
|
||||
set_awacs_3_reg(s, value);
|
||||
break;
|
||||
case 4:
|
||||
set_awacs_4_reg(s, value);
|
||||
break;
|
||||
case 5:
|
||||
set_awacs_5_reg(s, value);
|
||||
break;
|
||||
case 6:
|
||||
set_awacs_6_reg(s, value);
|
||||
break;
|
||||
case 7:
|
||||
set_awacs_7_reg(s, value);
|
||||
break;
|
||||
default:
|
||||
DPRINTF("Unhandled awacs registers %d\n", the_register);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Used to set the AWACS registers */
|
||||
static void set_codec_control_reg(ScreamerState *s, uint32_t value)
|
||||
{
|
||||
DPRINTF("set_codec_control_reg() called - value: 0x%x\n", value);
|
||||
s->codec_control = value;
|
||||
set_awacs_register(s, value);
|
||||
}
|
||||
|
||||
static void set_codec_status_reg(ScreamerState *s, uint32_t value)
|
||||
{
|
||||
DPRINTF("set_codec_status_reg() called - value: 0x%x\n", value);
|
||||
s->codec_status = value;
|
||||
}
|
||||
|
||||
static void set_clip_count_reg(ScreamerState *s, uint32_t new_value)
|
||||
{
|
||||
DPRINTF("set_clip_count_reg() called - value: 0x%x\n", new_value);
|
||||
s->clip_count = new_value;
|
||||
}
|
||||
|
||||
static void set_byte_swap_reg(ScreamerState *s, uint32_t value)
|
||||
{
|
||||
DPRINTF("set_byte_swap_reg() called - value: 0x%x\n", value);
|
||||
s->byte_swap = value;
|
||||
}
|
||||
|
||||
static void set_frame_count_reg(ScreamerState *s, uint32_t new_value)
|
||||
{
|
||||
DPRINTF("%s() called - value: 0x%x\n", __func__, new_value);
|
||||
s->frame_count = new_value;
|
||||
}
|
||||
|
||||
/*
|
||||
* Sets the busy bit of codec control register.
|
||||
* It is used to tell the CPU to wait.
|
||||
* value: the codec control register's value
|
||||
* bit_value: used to set or disable the busy bit
|
||||
*/
|
||||
static uint32_t set_busy_bit(uint32_t value, int bit_value)
|
||||
{
|
||||
const int busy_bit = 0x01000000;
|
||||
uint32_t return_value;
|
||||
if (bit_value == 1) /* Set this bit */
|
||||
return_value = (value | busy_bit);
|
||||
else /* bit_value == 0 Disable this bit */
|
||||
return_value = (value & ~busy_bit);
|
||||
return return_value;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Sets the part ready bit of the codec status register
|
||||
* value: the codec status register's value
|
||||
* bit_value: used to set or disable the part ready bit
|
||||
*/
|
||||
static uint32_t set_part_ready_bit(uint32_t value, int bit_value)
|
||||
{
|
||||
const int part_ready_bit = 0x00400000;
|
||||
uint32_t return_value;
|
||||
if (bit_value == 1) /* Set this bit */
|
||||
return_value = (value | part_ready_bit);
|
||||
else /* bit_value == 0 Disable this bit */
|
||||
return_value = (value & ~part_ready_bit);
|
||||
return return_value;
|
||||
}
|
||||
|
||||
/* Sets bits 12 and 13 to 1 to indicate the Screamer revision */
|
||||
static uint32_t set_revision(uint32_t input_value)
|
||||
{
|
||||
uint32_t return_value;
|
||||
return_value = input_value | 0x3000;
|
||||
return return_value;
|
||||
}
|
||||
|
||||
/* Sets bit 8 to indicate Crystal as the manufacturer */
|
||||
static uint32_t set_manufacturer(uint32_t input_value)
|
||||
{
|
||||
uint32_t return_value;
|
||||
return_value = input_value | 0x100;
|
||||
return return_value;
|
||||
}
|
||||
|
||||
|
||||
/************************** End of Setters *********************************/
|
||||
|
||||
|
||||
/*************************** DMA functions *********************************/
|
||||
|
||||
/*
|
||||
* Sends audio samples from a microphone or line-in to memory.
|
||||
* Used for sound input.
|
||||
* Currently only prevents a deadlock condition with Mac OS 9.
|
||||
*/
|
||||
static void screamer_to_dma(DBDMA_io *io)
|
||||
{
|
||||
DPRINTF("%s() called\n", __func__);
|
||||
ScreamerState *s = (ScreamerState *)io->opaque;
|
||||
DBDMAState *dbs = s->dbdma;
|
||||
DBDMA_channel *ch = &dbs->channels[0x12];
|
||||
ch->regs[DBDMA_STATUS] |= DEAD;
|
||||
ch->regs[DBDMA_STATUS] &= ~ACTIVE;
|
||||
io->dma_end(io);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
static void print_dma_info(DBDMA_io *io)
|
||||
{
|
||||
#define RUN 0x8000
|
||||
#define PAUSE 0x4000
|
||||
#define FLUSH 0x2000
|
||||
#define WAKE 0x1000
|
||||
#define DEAD 0x0800
|
||||
#define ACTIVE 0x0400
|
||||
#define BT 0x0100
|
||||
#define DEVSTAT 0x00ff
|
||||
|
||||
/*
|
||||
* RUN and PAUSE are bits under software control only.
|
||||
* FLUSH and WAKE are set by SW and cleared by hardware.
|
||||
* DEAD, ACTIVE and BT are only under hardware control.
|
||||
*/
|
||||
|
||||
DBDMA_channel *ch = io->channel;
|
||||
printf("DMA FLAGS: ");
|
||||
|
||||
if (ch->regs[DBDMA_STATUS] & RUN) {
|
||||
printf("RUN ");
|
||||
}
|
||||
|
||||
if (ch->regs[DBDMA_STATUS] & ACTIVE) {
|
||||
printf("ACTIVE ");
|
||||
}
|
||||
|
||||
if (ch->regs[DBDMA_STATUS] & PAUSE) {
|
||||
printf("PAUSE ");
|
||||
}
|
||||
|
||||
if (ch->regs[DBDMA_STATUS] & DEAD) {
|
||||
printf("DEAD ");
|
||||
}
|
||||
|
||||
if (ch->regs[DBDMA_STATUS] & WAKE) {
|
||||
printf("WAKE ");
|
||||
}
|
||||
|
||||
if (ch->regs[DBDMA_STATUS] & BT) {
|
||||
printf("BT ");
|
||||
}
|
||||
|
||||
if (ch->regs[DBDMA_STATUS] & DEVSTAT) {
|
||||
printf("DEVSTAT ");
|
||||
}
|
||||
|
||||
if (ch->regs[DBDMA_STATUS] & FLUSH) {
|
||||
printf("FLUSH ");
|
||||
}
|
||||
|
||||
if (ch->io.processing == true) {
|
||||
printf("processing ");
|
||||
}
|
||||
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
/* Tell the DMA controller we request more samples */
|
||||
static void dma_request(DBDMA_io *io)
|
||||
{
|
||||
DPRINTF("%s() called\n", __func__);
|
||||
if (DEBUG_SCREAMER) {
|
||||
print_dma_info(io);
|
||||
}
|
||||
io->len = 0;
|
||||
io->dma_end(io);
|
||||
}
|
||||
|
||||
|
||||
/* Adds sample data to the buffer */
|
||||
static void add_to_speaker_buffer(DBDMA_io *io)
|
||||
{
|
||||
ScreamerState *s = (ScreamerState *) io->opaque;
|
||||
|
||||
if (s->spk_buffer_position + io->len > MAX_BUFFER_SIZE) {
|
||||
/* postpone calling these samples until the buffer has been emptied */
|
||||
memcpy(&s->dma_io, io, sizeof(DBDMA_io));
|
||||
return;
|
||||
}
|
||||
dma_memory_read(&address_space_memory, io->addr,
|
||||
&s->spk_buffer[s->spk_buffer_position], io->len,
|
||||
MEMTXATTRS_UNSPECIFIED);
|
||||
s->spk_buffer_position += io->len;
|
||||
DPRINTF("%s() called - len: %d pos: %d/%d\n", __func__, io->len,
|
||||
s->spk_buffer_position, MAX_BUFFER_SIZE);
|
||||
|
||||
dma_request(io);
|
||||
}
|
||||
|
||||
/*
|
||||
* Called by the DMA chip to transfer samples from memory to the
|
||||
* Screamer chip.
|
||||
* Used for sound output.
|
||||
*/
|
||||
static void dma_to_screamer(DBDMA_io *io)
|
||||
{
|
||||
add_to_speaker_buffer(io);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* This will flush the audio buffer of previous audio - eliminating previous
|
||||
* audio playback.
|
||||
*/
|
||||
static void send_silence_to_speaker(ScreamerState *s)
|
||||
{
|
||||
DPRINTF("Silencing audio buffer...\n");
|
||||
int length = MAX_BUFFER_SIZE;
|
||||
s->spk_buffer_position = length;
|
||||
s->spk_play_position = 0;
|
||||
memset(s->spk_buffer, 0, length);
|
||||
s->dma_io.len = 0; /* stop any postponed samples from playing */
|
||||
}
|
||||
|
||||
|
||||
/* This is called after audio stops playing */
|
||||
static void dma_send_flush(DBDMA_io *io)
|
||||
{
|
||||
DPRINTF("dma_send_flush() called\n");
|
||||
if (DEBUG_SCREAMER) {
|
||||
print_dma_info(io);
|
||||
}
|
||||
ScreamerState *s = (ScreamerState *)io->opaque;
|
||||
reset_markers(s);
|
||||
send_silence_to_speaker(s);
|
||||
if (io->len > 0) {
|
||||
dma_request(io);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void dma_receive_flush(DBDMA_io *io)
|
||||
{
|
||||
DPRINTF("dma_receive_flush() called\n");
|
||||
}
|
||||
|
||||
|
||||
/* Set the functions the DMA system will call */
|
||||
void screamer_register_dma_functions(ScreamerState *s, void *dbdma,
|
||||
int send_channel, int receive_channel)
|
||||
{
|
||||
DPRINTF("%s() called\n", __func__);
|
||||
DPRINTF("send channel: %d\treceive channel: %d\n", send_channel,
|
||||
receive_channel);
|
||||
s->dbdma = dbdma;
|
||||
|
||||
/* Setup the DMA send system */
|
||||
DBDMA_register_channel(s->dbdma, send_channel, s->dma_send_irq,
|
||||
dma_to_screamer, dma_send_flush, s);
|
||||
|
||||
/* Setup the DMA receive system */
|
||||
DBDMA_register_channel(s->dbdma, receive_channel, s->dma_receive_irq,
|
||||
screamer_to_dma, dma_receive_flush, s);
|
||||
}
|
||||
|
||||
/************************* End of DMA functions **************************/
|
||||
|
||||
/* Resets this sound chip */
|
||||
static void screamer_reset(DeviceState *d)
|
||||
{
|
||||
DPRINTF("screamer_reset() called\n");
|
||||
ScreamerState *s = SCREAMER(d);
|
||||
set_sound_control_reg(s, 0);
|
||||
set_codec_control_reg(s, 0);
|
||||
set_codec_status_reg(s, 0);
|
||||
set_clip_count_reg(s, 0);
|
||||
set_byte_swap_reg(s, 0);
|
||||
set_frame_count_reg(s, 0);
|
||||
int i, num_awacs_regs = 8;
|
||||
for (i = 0; i < num_awacs_regs; i++) {
|
||||
s->awacs[i] = 0;
|
||||
}
|
||||
set_QEMU_audio_settings(s);
|
||||
reset_markers(s);
|
||||
s->dma_io.len = 0;
|
||||
}
|
||||
|
||||
/* Called when the CPU reads the memory addresses assigned to Screamer */
|
||||
static uint64_t screamer_mmio_read(void *opaque, hwaddr addr, unsigned size)
|
||||
{
|
||||
ScreamerState *state = opaque;
|
||||
uint32_t return_value;
|
||||
|
||||
addr = addr >> 4;
|
||||
switch (addr) {
|
||||
case SOUND_CONTROL_REG:
|
||||
return_value = get_sound_control_reg(state);
|
||||
break;
|
||||
case CODEC_CONTROL_REG:
|
||||
return_value = get_codec_control_reg(state);
|
||||
break;
|
||||
case CODEC_STATUS_REG:
|
||||
return_value = get_codec_status_reg(state);
|
||||
break;
|
||||
case CLIP_COUNT_REG:
|
||||
return_value = get_clip_count_reg(state);
|
||||
break;
|
||||
case BYTE_SWAP_REG:
|
||||
return_value = get_byte_swap_reg(state);
|
||||
break;
|
||||
case FRAME_COUNT_REG:
|
||||
return_value = get_frame_count_reg(state);
|
||||
break;
|
||||
default:
|
||||
DPRINTF("Unknown register read - addr:%" HWADDR_PRIx "\tsize:%d\n",
|
||||
addr, size);
|
||||
return_value = 12021981; /* Value used for debugging purposes */
|
||||
}
|
||||
DPRINTF("screamer_mmio_read() called addr: %" HWADDR_PRIx " size: %d",
|
||||
addr >> 4, size);
|
||||
DPRINTF(" returning 0x%x\n", return_value);
|
||||
return return_value;
|
||||
}
|
||||
|
||||
|
||||
/* Called when the CPU writes to the memory addresses assigned to Screamer */
|
||||
static void screamer_mmio_write(void *opaque, hwaddr addr, uint64_t raw_value,
|
||||
unsigned size)
|
||||
{
|
||||
DPRINTF("screamer_mmio_write() called - size: %d\n", size);
|
||||
ScreamerState *state = opaque;
|
||||
uint32_t value = raw_value & 0xffffffff;
|
||||
addr = addr >> 4;
|
||||
|
||||
switch (addr) {
|
||||
case SOUND_CONTROL_REG:
|
||||
set_sound_control_reg(state, value);
|
||||
break;
|
||||
case CODEC_CONTROL_REG:
|
||||
set_codec_control_reg(state, value);
|
||||
break;
|
||||
case CODEC_STATUS_REG:
|
||||
set_codec_status_reg(state, value);
|
||||
break;
|
||||
case CLIP_COUNT_REG:
|
||||
set_clip_count_reg(state, value);
|
||||
break;
|
||||
case BYTE_SWAP_REG:
|
||||
set_byte_swap_reg(state, value);
|
||||
break;
|
||||
case FRAME_COUNT_REG:
|
||||
set_frame_count_reg(state, value);
|
||||
break;
|
||||
default:
|
||||
DPRINTF("Unknown register write - addr:%" HWADDR_PRIx "\tvalue:%d\n",
|
||||
addr, value);
|
||||
}
|
||||
}
|
||||
|
||||
/* Used for memory_region_init_io() for memory mapped I/O */
|
||||
static const MemoryRegionOps screamer_ops = {
|
||||
.read = screamer_mmio_read,
|
||||
.write = screamer_mmio_write,
|
||||
.endianness = DEVICE_LITTLE_ENDIAN,
|
||||
.valid = {
|
||||
.min_access_size = 4,
|
||||
.max_access_size = 4
|
||||
}
|
||||
};
|
||||
|
||||
/* Called when the device has become active */
|
||||
static void screamer_realize(DeviceState *dev, Error **errp)
|
||||
{
|
||||
DPRINTF("screamer_realize() called\n");
|
||||
screamer_reset(dev);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Called when an instance of the Screamer device is created.
|
||||
* Also called when this HMP command is called: device_add screamer
|
||||
*/
|
||||
static void screamer_init(Object *obj)
|
||||
{
|
||||
DPRINTF("screamer_init() called\n");
|
||||
|
||||
ScreamerState *s = (ScreamerState *)obj;
|
||||
SysBusDevice *d = SYS_BUS_DEVICE(obj);
|
||||
const int region_size = 5 * 32;
|
||||
|
||||
/* Makes the read and write ops work */
|
||||
memory_region_init_io(&s->io_memory_region, OBJECT(s),
|
||||
&screamer_ops, s, SOUND_CHIP_NAME, region_size);
|
||||
|
||||
/* Sets the SysBusDevice's memory property */
|
||||
sysbus_init_mmio(d, &s->io_memory_region);
|
||||
|
||||
/* Setup all the interrupt requests */
|
||||
sysbus_init_irq(d, &s->irq);
|
||||
sysbus_init_irq(d, &s->dma_send_irq);
|
||||
sysbus_init_irq(d, &s->dma_receive_irq);
|
||||
|
||||
/* Registers Screamer with QEMU's audio system */
|
||||
AUD_register_card(SOUND_CHIP_NAME, &s->card);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* When saving and restoring the state of the VM, this is used to save and
|
||||
* restore the registers.
|
||||
*/
|
||||
static const VMStateDescription vmstate_screamer = {
|
||||
.name = "Screamer",
|
||||
.version_id = 1,
|
||||
.minimum_version_id = 1,
|
||||
.fields = (VMStateField[]) {
|
||||
VMSTATE_UINT16_ARRAY(awacs, ScreamerState, 8), /* 8 AWACS registers */
|
||||
VMSTATE_UINT32(sound_control, ScreamerState),
|
||||
VMSTATE_UINT32(codec_control, ScreamerState),
|
||||
VMSTATE_UINT32(codec_status, ScreamerState),
|
||||
VMSTATE_UINT32(clip_count, ScreamerState),
|
||||
VMSTATE_UINT32(byte_swap, ScreamerState),
|
||||
VMSTATE_UINT32(frame_count, ScreamerState),
|
||||
VMSTATE_END_OF_LIST()
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* Sets the class data. It is like polymorphism and inheritance in object
|
||||
* oriented languages.
|
||||
*/
|
||||
static void screamer_class_init(ObjectClass *class, void *data)
|
||||
{
|
||||
DPRINTF("screamer_class_init() called\n");
|
||||
DeviceClass *dc = DEVICE_CLASS(class);
|
||||
dc->realize = screamer_realize;
|
||||
dc->reset = screamer_reset;
|
||||
dc->desc = "Apple Screamer";
|
||||
dc->vmsd = &vmstate_screamer;
|
||||
dc->hotpluggable = false;
|
||||
}
|
||||
|
||||
/* Used for QOM function registration */
|
||||
static const TypeInfo screamer_info = {
|
||||
.name = "screamer",
|
||||
.parent = TYPE_SYS_BUS_DEVICE,
|
||||
.instance_size = sizeof(ScreamerState),
|
||||
.instance_init = screamer_init,
|
||||
.class_init = screamer_class_init,
|
||||
};
|
||||
|
||||
/* QOM registration of above functions for calling */
|
||||
static void screamer_register_types(void)
|
||||
{
|
||||
DPRINTF("screamer_register_types() called\n");
|
||||
type_register_static(&screamer_info);
|
||||
}
|
||||
|
||||
/* QEMU Object Model (QOM) stuff */
|
||||
type_init(screamer_register_types)
|
||||
@@ -127,8 +127,7 @@ bool virtio_blk_data_plane_create(VirtIODevice *vdev, VirtIOBlkConf *conf,
|
||||
} else {
|
||||
s->ctx = qemu_get_aio_context();
|
||||
}
|
||||
s->bh = aio_bh_new_guarded(s->ctx, notify_guest_bh, s,
|
||||
&DEVICE(vdev)->mem_reentrancy_guard);
|
||||
s->bh = aio_bh_new(s->ctx, notify_guest_bh, s);
|
||||
s->batch_notify_vqs = bitmap_new(conf->num_queues);
|
||||
|
||||
*dataplane = s;
|
||||
|
||||
@@ -632,9 +632,8 @@ XenBlockDataPlane *xen_block_dataplane_create(XenDevice *xendev,
|
||||
} else {
|
||||
dataplane->ctx = qemu_get_aio_context();
|
||||
}
|
||||
dataplane->bh = aio_bh_new_guarded(dataplane->ctx, xen_block_dataplane_bh,
|
||||
dataplane,
|
||||
&DEVICE(xendev)->mem_reentrancy_guard);
|
||||
dataplane->bh = aio_bh_new(dataplane->ctx, xen_block_dataplane_bh,
|
||||
dataplane);
|
||||
|
||||
return dataplane;
|
||||
}
|
||||
|
||||
+17
-38
@@ -84,11 +84,7 @@ struct NANDFlashState {
|
||||
|
||||
void (*blk_write)(NANDFlashState *s);
|
||||
void (*blk_erase)(NANDFlashState *s);
|
||||
/*
|
||||
* Returns %true when block containing (@addr + @offset) is
|
||||
* successfully loaded, otherwise %false.
|
||||
*/
|
||||
bool (*blk_load)(NANDFlashState *s, uint64_t addr, unsigned offset);
|
||||
void (*blk_load)(NANDFlashState *s, uint64_t addr, int offset);
|
||||
|
||||
uint32_t ioaddr_vmstate;
|
||||
};
|
||||
@@ -247,30 +243,9 @@ static inline void nand_pushio_byte(NANDFlashState *s, uint8_t value)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* nand_load_block: Load block containing (s->addr + @offset).
|
||||
* Returns length of data available at @offset in this block.
|
||||
*/
|
||||
static unsigned nand_load_block(NANDFlashState *s, unsigned offset)
|
||||
{
|
||||
unsigned iolen;
|
||||
|
||||
if (!s->blk_load(s, s->addr, offset)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
iolen = (1 << s->page_shift);
|
||||
if (s->gnd) {
|
||||
iolen += 1 << s->oob_shift;
|
||||
}
|
||||
assert(offset <= iolen);
|
||||
iolen -= offset;
|
||||
|
||||
return iolen;
|
||||
}
|
||||
|
||||
static void nand_command(NANDFlashState *s)
|
||||
{
|
||||
unsigned int offset;
|
||||
switch (s->cmd) {
|
||||
case NAND_CMD_READ0:
|
||||
s->iolen = 0;
|
||||
@@ -296,7 +271,12 @@ static void nand_command(NANDFlashState *s)
|
||||
case NAND_CMD_NOSERIALREAD2:
|
||||
if (!(nand_flash_ids[s->chip_id].options & NAND_SAMSUNG_LP))
|
||||
break;
|
||||
s->iolen = nand_load_block(s, s->addr & ((1 << s->addr_shift) - 1));
|
||||
offset = s->addr & ((1 << s->addr_shift) - 1);
|
||||
s->blk_load(s, s->addr, offset);
|
||||
if (s->gnd)
|
||||
s->iolen = (1 << s->page_shift) - offset;
|
||||
else
|
||||
s->iolen = (1 << s->page_shift) + (1 << s->oob_shift) - offset;
|
||||
break;
|
||||
|
||||
case NAND_CMD_RESET:
|
||||
@@ -617,7 +597,12 @@ uint32_t nand_getio(DeviceState *dev)
|
||||
if (!s->iolen && s->cmd == NAND_CMD_READ0) {
|
||||
offset = (int) (s->addr & ((1 << s->addr_shift) - 1)) + s->offset;
|
||||
s->offset = 0;
|
||||
s->iolen = nand_load_block(s, offset);
|
||||
|
||||
s->blk_load(s, s->addr, offset);
|
||||
if (s->gnd)
|
||||
s->iolen = (1 << s->page_shift) - offset;
|
||||
else
|
||||
s->iolen = (1 << s->page_shift) + (1 << s->oob_shift) - offset;
|
||||
}
|
||||
|
||||
if (s->ce || s->iolen <= 0) {
|
||||
@@ -778,15 +763,11 @@ static void glue(nand_blk_erase_, NAND_PAGE_SIZE)(NANDFlashState *s)
|
||||
}
|
||||
}
|
||||
|
||||
static bool glue(nand_blk_load_, NAND_PAGE_SIZE)(NANDFlashState *s,
|
||||
uint64_t addr, unsigned offset)
|
||||
static void glue(nand_blk_load_, NAND_PAGE_SIZE)(NANDFlashState *s,
|
||||
uint64_t addr, int offset)
|
||||
{
|
||||
if (PAGE(addr) >= s->pages) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (offset > NAND_PAGE_SIZE + OOB_SIZE) {
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (s->blk) {
|
||||
@@ -814,8 +795,6 @@ static bool glue(nand_blk_load_, NAND_PAGE_SIZE)(NANDFlashState *s,
|
||||
offset, NAND_PAGE_SIZE + OOB_SIZE - offset);
|
||||
s->ioaddr = s->io;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static void glue(nand_init_, NAND_PAGE_SIZE)(NANDFlashState *s)
|
||||
|
||||
+80
-91
@@ -81,39 +81,16 @@ struct PFlashCFI01 {
|
||||
uint16_t ident3;
|
||||
uint8_t cfi_table[0x52];
|
||||
uint64_t counter;
|
||||
uint32_t writeblock_size;
|
||||
unsigned int writeblock_size;
|
||||
MemoryRegion mem;
|
||||
char *name;
|
||||
void *storage;
|
||||
VMChangeStateEntry *vmstate;
|
||||
bool old_multiple_chip_handling;
|
||||
|
||||
/* block update buffer */
|
||||
unsigned char *blk_bytes;
|
||||
uint32_t blk_offset;
|
||||
};
|
||||
|
||||
static int pflash_post_load(void *opaque, int version_id);
|
||||
|
||||
static bool pflash_blk_write_state_needed(void *opaque)
|
||||
{
|
||||
PFlashCFI01 *pfl = opaque;
|
||||
|
||||
return (pfl->blk_offset != -1);
|
||||
}
|
||||
|
||||
static const VMStateDescription vmstate_pflash_blk_write = {
|
||||
.name = "pflash_cfi01_blk_write",
|
||||
.version_id = 1,
|
||||
.minimum_version_id = 1,
|
||||
.needed = pflash_blk_write_state_needed,
|
||||
.fields = (const VMStateField[]) {
|
||||
VMSTATE_VBUFFER_UINT32(blk_bytes, PFlashCFI01, 0, NULL, writeblock_size),
|
||||
VMSTATE_UINT32(blk_offset, PFlashCFI01),
|
||||
VMSTATE_END_OF_LIST()
|
||||
}
|
||||
};
|
||||
|
||||
static const VMStateDescription vmstate_pflash = {
|
||||
.name = "pflash_cfi01",
|
||||
.version_id = 1,
|
||||
@@ -125,10 +102,6 @@ static const VMStateDescription vmstate_pflash = {
|
||||
VMSTATE_UINT8(status, PFlashCFI01),
|
||||
VMSTATE_UINT64(counter, PFlashCFI01),
|
||||
VMSTATE_END_OF_LIST()
|
||||
},
|
||||
.subsections = (const VMStateDescription * []) {
|
||||
&vmstate_pflash_blk_write,
|
||||
NULL
|
||||
}
|
||||
};
|
||||
|
||||
@@ -253,10 +226,34 @@ static uint32_t pflash_data_read(PFlashCFI01 *pfl, hwaddr offset,
|
||||
uint32_t ret;
|
||||
|
||||
p = pfl->storage;
|
||||
if (be) {
|
||||
ret = ldn_be_p(p + offset, width);
|
||||
} else {
|
||||
ret = ldn_le_p(p + offset, width);
|
||||
switch (width) {
|
||||
case 1:
|
||||
ret = p[offset];
|
||||
break;
|
||||
case 2:
|
||||
if (be) {
|
||||
ret = p[offset] << 8;
|
||||
ret |= p[offset + 1];
|
||||
} else {
|
||||
ret = p[offset];
|
||||
ret |= p[offset + 1] << 8;
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
if (be) {
|
||||
ret = p[offset] << 24;
|
||||
ret |= p[offset + 1] << 16;
|
||||
ret |= p[offset + 2] << 8;
|
||||
ret |= p[offset + 3];
|
||||
} else {
|
||||
ret = p[offset];
|
||||
ret |= p[offset + 1] << 8;
|
||||
ret |= p[offset + 2] << 16;
|
||||
ret |= p[offset + 3] << 24;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
abort();
|
||||
}
|
||||
trace_pflash_data_read(pfl->name, offset, width, ret);
|
||||
return ret;
|
||||
@@ -404,61 +401,40 @@ static void pflash_update(PFlashCFI01 *pfl, int offset,
|
||||
}
|
||||
}
|
||||
|
||||
/* copy current flash content to block update buffer */
|
||||
static void pflash_blk_write_start(PFlashCFI01 *pfl, hwaddr offset)
|
||||
{
|
||||
hwaddr mask = ~(pfl->writeblock_size - 1);
|
||||
|
||||
trace_pflash_write_block_start(pfl->name, pfl->counter);
|
||||
pfl->blk_offset = offset & mask;
|
||||
memcpy(pfl->blk_bytes, pfl->storage + pfl->blk_offset,
|
||||
pfl->writeblock_size);
|
||||
}
|
||||
|
||||
/* commit block update buffer changes */
|
||||
static void pflash_blk_write_flush(PFlashCFI01 *pfl)
|
||||
{
|
||||
g_assert(pfl->blk_offset != -1);
|
||||
trace_pflash_write_block_flush(pfl->name);
|
||||
memcpy(pfl->storage + pfl->blk_offset, pfl->blk_bytes,
|
||||
pfl->writeblock_size);
|
||||
pflash_update(pfl, pfl->blk_offset, pfl->writeblock_size);
|
||||
pfl->blk_offset = -1;
|
||||
}
|
||||
|
||||
/* discard block update buffer changes */
|
||||
static void pflash_blk_write_abort(PFlashCFI01 *pfl)
|
||||
{
|
||||
trace_pflash_write_block_abort(pfl->name);
|
||||
pfl->blk_offset = -1;
|
||||
}
|
||||
|
||||
static inline void pflash_data_write(PFlashCFI01 *pfl, hwaddr offset,
|
||||
uint32_t value, int width, int be)
|
||||
{
|
||||
uint8_t *p;
|
||||
uint8_t *p = pfl->storage;
|
||||
|
||||
if (pfl->blk_offset != -1) {
|
||||
/* block write: redirect writes to block update buffer */
|
||||
if ((offset < pfl->blk_offset) ||
|
||||
(offset + width > pfl->blk_offset + pfl->writeblock_size)) {
|
||||
pfl->status |= 0x10; /* Programming error */
|
||||
return;
|
||||
trace_pflash_data_write(pfl->name, offset, width, value, pfl->counter);
|
||||
switch (width) {
|
||||
case 1:
|
||||
p[offset] = value;
|
||||
break;
|
||||
case 2:
|
||||
if (be) {
|
||||
p[offset] = value >> 8;
|
||||
p[offset + 1] = value;
|
||||
} else {
|
||||
p[offset] = value;
|
||||
p[offset + 1] = value >> 8;
|
||||
}
|
||||
trace_pflash_data_write_block(pfl->name, offset, width, value,
|
||||
pfl->counter);
|
||||
p = pfl->blk_bytes + (offset - pfl->blk_offset);
|
||||
} else {
|
||||
/* write directly to storage */
|
||||
trace_pflash_data_write(pfl->name, offset, width, value);
|
||||
p = pfl->storage + offset;
|
||||
break;
|
||||
case 4:
|
||||
if (be) {
|
||||
p[offset] = value >> 24;
|
||||
p[offset + 1] = value >> 16;
|
||||
p[offset + 2] = value >> 8;
|
||||
p[offset + 3] = value;
|
||||
} else {
|
||||
p[offset] = value;
|
||||
p[offset + 1] = value >> 8;
|
||||
p[offset + 2] = value >> 16;
|
||||
p[offset + 3] = value >> 24;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (be) {
|
||||
stn_be_p(p, width, value);
|
||||
} else {
|
||||
stn_le_p(p, width, value);
|
||||
}
|
||||
}
|
||||
|
||||
static void pflash_write(PFlashCFI01 *pfl, hwaddr offset,
|
||||
@@ -573,9 +549,9 @@ static void pflash_write(PFlashCFI01 *pfl, hwaddr offset,
|
||||
} else {
|
||||
value = extract32(value, 0, pfl->bank_width * 8);
|
||||
}
|
||||
trace_pflash_write_block(pfl->name, value);
|
||||
pfl->counter = value;
|
||||
pfl->wcycle++;
|
||||
pflash_blk_write_start(pfl, offset);
|
||||
break;
|
||||
case 0x60:
|
||||
if (cmd == 0xd0) {
|
||||
@@ -606,7 +582,12 @@ static void pflash_write(PFlashCFI01 *pfl, hwaddr offset,
|
||||
switch (pfl->cmd) {
|
||||
case 0xe8: /* Block write */
|
||||
/* FIXME check @offset, @width */
|
||||
if (!pfl->ro && (pfl->blk_offset != -1)) {
|
||||
if (!pfl->ro) {
|
||||
/*
|
||||
* FIXME writing straight to memory is *wrong*. We
|
||||
* should write to a buffer, and flush it to memory
|
||||
* only on confirm command (see below).
|
||||
*/
|
||||
pflash_data_write(pfl, offset, value, width, be);
|
||||
} else {
|
||||
pfl->status |= 0x10; /* Programming error */
|
||||
@@ -615,8 +596,18 @@ static void pflash_write(PFlashCFI01 *pfl, hwaddr offset,
|
||||
pfl->status |= 0x80;
|
||||
|
||||
if (!pfl->counter) {
|
||||
hwaddr mask = pfl->writeblock_size - 1;
|
||||
mask = ~mask;
|
||||
|
||||
trace_pflash_write(pfl->name, "block write finished");
|
||||
pfl->wcycle++;
|
||||
if (!pfl->ro) {
|
||||
/* Flush the entire write buffer onto backing storage. */
|
||||
/* FIXME premature! */
|
||||
pflash_update(pfl, offset & mask, pfl->writeblock_size);
|
||||
} else {
|
||||
pfl->status |= 0x10; /* Programming error */
|
||||
}
|
||||
}
|
||||
|
||||
pfl->counter--;
|
||||
@@ -628,17 +619,20 @@ static void pflash_write(PFlashCFI01 *pfl, hwaddr offset,
|
||||
case 3: /* Confirm mode */
|
||||
switch (pfl->cmd) {
|
||||
case 0xe8: /* Block write */
|
||||
if ((cmd == 0xd0) && !(pfl->status & 0x10)) {
|
||||
pflash_blk_write_flush(pfl);
|
||||
if (cmd == 0xd0) {
|
||||
/* FIXME this is where we should write out the buffer */
|
||||
pfl->wcycle = 0;
|
||||
pfl->status |= 0x80;
|
||||
} else {
|
||||
pflash_blk_write_abort(pfl);
|
||||
qemu_log_mask(LOG_UNIMP,
|
||||
"%s: Aborting write to buffer not implemented,"
|
||||
" the data is already written to storage!\n"
|
||||
"Flash device reset into READ mode.\n",
|
||||
__func__);
|
||||
goto mode_read_array;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
pflash_blk_write_abort(pfl);
|
||||
goto error_flash;
|
||||
}
|
||||
break;
|
||||
@@ -872,9 +866,6 @@ static void pflash_cfi01_realize(DeviceState *dev, Error **errp)
|
||||
pfl->cmd = 0x00;
|
||||
pfl->status = 0x80; /* WSM ready */
|
||||
pflash_cfi01_fill_cfi_table(pfl);
|
||||
|
||||
pfl->blk_bytes = g_malloc(pfl->writeblock_size);
|
||||
pfl->blk_offset = -1;
|
||||
}
|
||||
|
||||
static void pflash_cfi01_system_reset(DeviceState *dev)
|
||||
@@ -894,8 +885,6 @@ static void pflash_cfi01_system_reset(DeviceState *dev)
|
||||
* This model deliberately ignores this delay.
|
||||
*/
|
||||
pfl->status = 0x80;
|
||||
|
||||
pfl->blk_offset = -1;
|
||||
}
|
||||
|
||||
static Property pflash_cfi01_properties[] = {
|
||||
|
||||
@@ -546,7 +546,7 @@ static void pflash_write(void *opaque, hwaddr offset, uint64_t value,
|
||||
}
|
||||
goto reset_flash;
|
||||
}
|
||||
trace_pflash_data_write(pfl->name, offset, width, value);
|
||||
trace_pflash_data_write(pfl->name, offset, width, value, 0);
|
||||
if (!pfl->ro) {
|
||||
p = (uint8_t *)pfl->storage + offset;
|
||||
if (pfl->be) {
|
||||
|
||||
@@ -12,8 +12,7 @@ fdctrl_tc_pulse(int level) "TC pulse: %u"
|
||||
pflash_chip_erase_invalid(const char *name, uint64_t offset) "%s: chip erase: invalid address 0x%" PRIx64
|
||||
pflash_chip_erase_start(const char *name) "%s: start chip erase"
|
||||
pflash_data_read(const char *name, uint64_t offset, unsigned size, uint32_t value) "%s: data offset:0x%04"PRIx64" size:%u value:0x%04x"
|
||||
pflash_data_write(const char *name, uint64_t offset, unsigned size, uint32_t value) "%s: data offset:0x%04"PRIx64" size:%u value:0x%04x"
|
||||
pflash_data_write_block(const char *name, uint64_t offset, unsigned size, uint32_t value, uint64_t counter) "%s: data offset:0x%04"PRIx64" size:%u value:0x%04x counter:0x%016"PRIx64
|
||||
pflash_data_write(const char *name, uint64_t offset, unsigned size, uint32_t value, uint64_t counter) "%s: data offset:0x%04"PRIx64" size:%u value:0x%04x counter:0x%016"PRIx64
|
||||
pflash_device_id(const char *name, uint16_t id) "%s: read device ID: 0x%04x"
|
||||
pflash_device_info(const char *name, uint64_t offset) "%s: read device information offset:0x%04" PRIx64
|
||||
pflash_erase_complete(const char *name) "%s: sector erase complete"
|
||||
@@ -33,9 +32,7 @@ pflash_unlock0_failed(const char *name, uint64_t offset, uint8_t cmd, uint16_t a
|
||||
pflash_unlock1_failed(const char *name, uint64_t offset, uint8_t cmd) "%s: unlock0 failed 0x%" PRIx64 " 0x%02x"
|
||||
pflash_unsupported_device_configuration(const char *name, uint8_t width, uint8_t max) "%s: unsupported device configuration: device_width:%d max_device_width:%d"
|
||||
pflash_write(const char *name, const char *str) "%s: %s"
|
||||
pflash_write_block_start(const char *name, uint32_t value) "%s: block write start: bytes:0x%x"
|
||||
pflash_write_block_flush(const char *name) "%s: block write flush"
|
||||
pflash_write_block_abort(const char *name) "%s: block write abort"
|
||||
pflash_write_block(const char *name, uint32_t value) "%s: block write: bytes:0x%x"
|
||||
pflash_write_block_erase(const char *name, uint64_t offset, uint64_t len) "%s: block erase offset:0x%" PRIx64 " bytes:0x%" PRIx64
|
||||
pflash_write_failed(const char *name, uint64_t offset, uint8_t cmd) "%s: command failed 0x%" PRIx64 " 0x%02x"
|
||||
pflash_write_invalid(const char *name, uint8_t cmd) "%s: invalid write for command 0x%02x"
|
||||
|
||||
@@ -759,15 +759,14 @@ static XenBlockDrive *xen_block_drive_create(const char *id,
|
||||
drive = g_new0(XenBlockDrive, 1);
|
||||
drive->id = g_strdup(id);
|
||||
|
||||
file_layer = qdict_new();
|
||||
driver_layer = qdict_new();
|
||||
|
||||
rc = stat(filename, &st);
|
||||
if (rc) {
|
||||
error_setg_errno(errp, errno, "Could not stat file '%s'", filename);
|
||||
goto done;
|
||||
}
|
||||
|
||||
file_layer = qdict_new();
|
||||
driver_layer = qdict_new();
|
||||
|
||||
if (S_ISBLK(st.st_mode)) {
|
||||
qdict_put_str(file_layer, "driver", "host_device");
|
||||
} else {
|
||||
@@ -775,6 +774,7 @@ static XenBlockDrive *xen_block_drive_create(const char *id,
|
||||
}
|
||||
|
||||
qdict_put_str(file_layer, "filename", filename);
|
||||
g_free(filename);
|
||||
|
||||
if (mode && *mode != 'w') {
|
||||
qdict_put_bool(file_layer, "read-only", true);
|
||||
@@ -809,6 +809,7 @@ static XenBlockDrive *xen_block_drive_create(const char *id,
|
||||
qdict_put_str(file_layer, "locking", "off");
|
||||
|
||||
qdict_put_str(driver_layer, "driver", driver);
|
||||
g_free(driver);
|
||||
|
||||
qdict_put(driver_layer, "file", file_layer);
|
||||
|
||||
@@ -819,8 +820,6 @@ static XenBlockDrive *xen_block_drive_create(const char *id,
|
||||
qobject_unref(driver_layer);
|
||||
|
||||
done:
|
||||
g_free(filename);
|
||||
g_free(driver);
|
||||
if (*errp) {
|
||||
xen_block_drive_destroy(drive, NULL);
|
||||
return NULL;
|
||||
|
||||
@@ -146,8 +146,7 @@ static void htif_handle_tohost_write(HTIFState *htifstate, uint64_t val_written)
|
||||
htifstate->env->mtohost = 0; /* clear to indicate we read */
|
||||
return;
|
||||
} else if (cmd == 0x1) {
|
||||
uint8_t ch = (uint8_t)payload;
|
||||
qemu_chr_fe_write(&htifstate->chr, &ch, 1);
|
||||
qemu_chr_fe_write(&htifstate->chr, (uint8_t *)&payload, 1);
|
||||
resp = 0x100 | (uint8_t)payload;
|
||||
} else {
|
||||
qemu_log("HTIF device %d: unknown command\n", device);
|
||||
|
||||
@@ -985,7 +985,7 @@ static void virtser_port_device_realize(DeviceState *dev, Error **errp)
|
||||
return;
|
||||
}
|
||||
|
||||
port->bh = virtio_bh_new_guarded(dev, flush_queued_data_bh, port);
|
||||
port->bh = qemu_bh_new(flush_queued_data_bh, port);
|
||||
port->elem = NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -193,13 +193,3 @@ void machine_parse_smp_config(MachineState *ms,
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
unsigned int machine_topo_get_cores_per_socket(const MachineState *ms)
|
||||
{
|
||||
return ms->smp.cores * ms->smp.clusters * ms->smp.dies;
|
||||
}
|
||||
|
||||
unsigned int machine_topo_get_threads_per_socket(const MachineState *ms)
|
||||
{
|
||||
return ms->smp.threads * machine_topo_get_cores_per_socket(ms);
|
||||
}
|
||||
@@ -42,9 +42,6 @@
|
||||
|
||||
GlobalProperty hw_compat_7_1[] = {
|
||||
{ "virtio-device", "queue_reset", "false" },
|
||||
{ "virtio-rng-pci", "vectors", "0" },
|
||||
{ "virtio-rng-pci-transitional", "vectors", "0" },
|
||||
{ "virtio-rng-pci-non-transitional", "vectors", "0" },
|
||||
};
|
||||
const size_t hw_compat_7_1_len = G_N_ELEMENTS(hw_compat_7_1);
|
||||
|
||||
@@ -80,7 +77,6 @@ GlobalProperty hw_compat_5_2[] = {
|
||||
{ "PIIX4_PM", "smm-compat", "on"},
|
||||
{ "virtio-blk-device", "report-discard-granularity", "off" },
|
||||
{ "virtio-net-pci-base", "vectors", "3"},
|
||||
{ "nvme", "msix-exclusive-bar", "on"},
|
||||
};
|
||||
const size_t hw_compat_5_2_len = G_N_ELEMENTS(hw_compat_5_2);
|
||||
|
||||
@@ -1330,14 +1326,6 @@ void machine_run_board_init(MachineState *machine, const char *mem_path, Error *
|
||||
}
|
||||
} else if (machine_class->default_ram_id && machine->ram_size &&
|
||||
numa_uses_legacy_mem()) {
|
||||
if (object_property_find(object_get_objects_root(),
|
||||
machine_class->default_ram_id)) {
|
||||
error_setg(errp, "object name '%s' is reserved for the default"
|
||||
" RAM backend, it can't be used for any other purposes."
|
||||
" Change the object's 'id' to something else",
|
||||
machine_class->default_ram_id);
|
||||
return;
|
||||
}
|
||||
if (!create_default_memdev(current_machine, mem_path, errp)) {
|
||||
return;
|
||||
}
|
||||
|
||||
+3
-8
@@ -49,7 +49,6 @@ static void ct3_build_cdat(CDATObject *cdat, Error **errp)
|
||||
g_autofree CDATTableHeader *cdat_header = NULL;
|
||||
g_autofree CDATEntry *cdat_st = NULL;
|
||||
uint8_t sum = 0;
|
||||
uint8_t *hdr_buf;
|
||||
int ent, i;
|
||||
|
||||
/* Use default table if fopen == NULL */
|
||||
@@ -63,7 +62,7 @@ static void ct3_build_cdat(CDATObject *cdat, Error **errp)
|
||||
|
||||
cdat->built_buf_len = cdat->build_cdat_table(&cdat->built_buf, cdat->private);
|
||||
|
||||
if (cdat->built_buf_len <= 0) {
|
||||
if (!cdat->built_buf_len) {
|
||||
/* Build later as not all data available yet */
|
||||
cdat->to_update = true;
|
||||
return;
|
||||
@@ -95,12 +94,8 @@ static void ct3_build_cdat(CDATObject *cdat, Error **errp)
|
||||
/* For now, no runtime updates */
|
||||
cdat_header->sequence = 0;
|
||||
cdat_header->length += sizeof(CDATTableHeader);
|
||||
|
||||
hdr_buf = (uint8_t *)cdat_header;
|
||||
for (i = 0; i < sizeof(*cdat_header); i++) {
|
||||
sum += hdr_buf[i];
|
||||
}
|
||||
|
||||
sum += cdat_header->revision + cdat_header->sequence +
|
||||
cdat_header->length;
|
||||
/* Sum of all bytes including checksum must be 0 */
|
||||
cdat_header->checksum = ~sum + 1;
|
||||
|
||||
|
||||
@@ -126,7 +126,7 @@ void cxl_component_register_block_init(Object *obj,
|
||||
/* io registers controls link which we don't care about in QEMU */
|
||||
memory_region_init_io(&cregs->io, obj, NULL, cregs, ".io",
|
||||
CXL2_COMPONENT_IO_REGION_SIZE);
|
||||
memory_region_init_io(&cregs->cache_mem, obj, &cache_mem_ops, cxl_cstate,
|
||||
memory_region_init_io(&cregs->cache_mem, obj, &cache_mem_ops, cregs,
|
||||
".cache_mem", CXL2_COMPONENT_CM_REGION_SIZE);
|
||||
|
||||
memory_region_add_subregion(&cregs->component_registers, 0, &cregs->io);
|
||||
|
||||
Loaded 100 of 630 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user