!893 [sync] PR-877: qemu升级至8.2.0
From: @openeuler-sync-bot Reviewed-by: @aven6 Signed-off-by: @aven6
This commit is contained in:
commit
f6f3a33f0e
@ -1,172 +0,0 @@
|
|||||||
From beed3295acf786cec520a8a0aec5efcd2ca12b23 Mon Sep 17 00:00:00 2001
|
|
||||||
From: liuxiangdong <liuxiangdong5@huawei.com>
|
|
||||||
Date: Fri, 14 Jul 2023 05:11:57 +0800
|
|
||||||
Subject: [PATCH] 9pfs: prevent opening special files (CVE-2023-2861) The 9p
|
|
||||||
protocol does not specifically define how server shall behave when client
|
|
||||||
tries to open a special file, however from security POV it does make sense
|
|
||||||
for 9p server to prohibit opening any special file on host side in general. A
|
|
||||||
sane Linux 9p client for instance would never attempt to open a special file
|
|
||||||
on host side, it would always handle those exclusively on its guest side. A
|
|
||||||
malicious client however could potentially escape from the exported 9p tree
|
|
||||||
by creating and opening a device file on host side.
|
|
||||||
|
|
||||||
With QEMU this could only be exploited in the following unsafe setups:
|
|
||||||
|
|
||||||
- Running QEMU binary as root AND 9p 'local' fs driver AND 'passthrough'
|
|
||||||
security model.
|
|
||||||
|
|
||||||
or
|
|
||||||
|
|
||||||
- Using 9p 'proxy' fs driver (which is running its helper daemon as
|
|
||||||
root).
|
|
||||||
|
|
||||||
These setups were already discouraged for safety reasons before,
|
|
||||||
however for obvious reasons we are now tightening behaviour on this.
|
|
||||||
|
|
||||||
Fixes: CVE-2023-2861
|
|
||||||
Reported-by: Yanwu Shen <ywsPlz@gmail.com>
|
|
||||||
Reported-by: Jietao Xiao <shawtao1125@gmail.com>
|
|
||||||
Reported-by: Jinku Li <jkli@xidian.edu.cn>
|
|
||||||
Reported-by: Wenbo Shen <shenwenbo@zju.edu.cn>
|
|
||||||
Signed-off-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
|
|
||||||
Reviewed-by: Greg Kurz <groug@kaod.org>
|
|
||||||
Reviewed-by: Michael Tokarev <mjt@tls.msk.ru>
|
|
||||||
Message-Id: <E1q6w7r-0000Q0-NM@lizzy.crudebyte.com>
|
|
||||||
---
|
|
||||||
fsdev/virtfs-proxy-helper.c | 27 +++++++++++++++++++++++--
|
|
||||||
hw/9pfs/9p-util.h | 40 +++++++++++++++++++++++++++++++++++++
|
|
||||||
2 files changed, 65 insertions(+), 2 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/fsdev/virtfs-proxy-helper.c b/fsdev/virtfs-proxy-helper.c
|
|
||||||
index 15c0e79b06..f9e4669a5b 100644
|
|
||||||
--- a/fsdev/virtfs-proxy-helper.c
|
|
||||||
+++ b/fsdev/virtfs-proxy-helper.c
|
|
||||||
@@ -26,6 +26,7 @@
|
|
||||||
#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"
|
|
||||||
@@ -338,6 +339,28 @@ 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
|
|
||||||
@@ -682,7 +705,7 @@ static int do_create(struct iovec *iovec)
|
|
||||||
if (ret < 0) {
|
|
||||||
goto unmarshal_err_out;
|
|
||||||
}
|
|
||||||
- ret = open(path.data, flags, mode);
|
|
||||||
+ ret = open_regular(path.data, flags, mode);
|
|
||||||
if (ret < 0) {
|
|
||||||
ret = -errno;
|
|
||||||
}
|
|
||||||
@@ -707,7 +730,7 @@ static int do_open(struct iovec *iovec)
|
|
||||||
if (ret < 0) {
|
|
||||||
goto err_out;
|
|
||||||
}
|
|
||||||
- ret = open(path.data, flags);
|
|
||||||
+ ret = open_regular(path.data, flags, 0);
|
|
||||||
if (ret < 0) {
|
|
||||||
ret = -errno;
|
|
||||||
}
|
|
||||||
diff --git a/hw/9pfs/9p-util.h b/hw/9pfs/9p-util.h
|
|
||||||
index 546f46dc7d..23000e917f 100644
|
|
||||||
--- a/hw/9pfs/9p-util.h
|
|
||||||
+++ b/hw/9pfs/9p-util.h
|
|
||||||
@@ -13,12 +13,16 @@
|
|
||||||
#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
|
|
||||||
#define O_PATH_9P_UTIL 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
+#define qemu_fstat fstat
|
|
||||||
+
|
|
||||||
static inline void close_preserve_errno(int fd)
|
|
||||||
{
|
|
||||||
int serrno = errno;
|
|
||||||
@@ -26,6 +30,38 @@ 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 (qemu_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,
|
|
||||||
@@ -56,6 +92,10 @@ 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()
|
|
||||||
--
|
|
||||||
2.41.0.windows.1
|
|
||||||
|
|
||||||
@ -1,310 +0,0 @@
|
|||||||
From 4d572573175449f48fc12c9f9524fc09f219cdbd Mon Sep 17 00:00:00 2001
|
|
||||||
From: ling xu <ling1.xu@intel.com>
|
|
||||||
Date: Wed, 16 Nov 2022 23:29:22 +0800
|
|
||||||
Subject: [PATCH] AVX512 support for xbzrle_encode_buffer
|
|
||||||
|
|
||||||
mainline inclusion
|
|
||||||
from mainline-v8.0.0-rc0
|
|
||||||
commit 04ffce137b6d85ab4e7687e54e4dffcef0a9ab99
|
|
||||||
category: feature
|
|
||||||
feature: AVX512 support for xbzrle_encode_buffer
|
|
||||||
bugzilla: https://gitee.com/openeuler/intel-qemu/issues/I6Z50P
|
|
||||||
|
|
||||||
Intel-SIG: commit 04ffce137b6d ("AVX512 support for xbzrle_encode_buffer")
|
|
||||||
|
|
||||||
-------------------------------------
|
|
||||||
|
|
||||||
AVX512 support for xbzrle_encode_buffer
|
|
||||||
|
|
||||||
This commit is the same with [PATCH v6 1/2], and provides avx512 support for xbzrle_encode_buffer
|
|
||||||
function to accelerate xbzrle encoding speed. Runtime check of avx512
|
|
||||||
support and benchmark for this feature are added. Compared with C
|
|
||||||
version of xbzrle_encode_buffer function, avx512 version can achieve
|
|
||||||
50%-70% performance improvement on benchmarking. In addition, if dirty
|
|
||||||
data is randomly located in 4K page, the avx512 version can achieve
|
|
||||||
almost 140% performance gain.
|
|
||||||
|
|
||||||
Signed-off-by: ling xu <ling1.xu@intel.com>
|
|
||||||
Co-authored-by: Zhou Zhao <zhou.zhao@intel.com>
|
|
||||||
Co-authored-by: Jun Jin <jun.i.jin@intel.com>
|
|
||||||
Reviewed-by: Juan Quintela <quintela@redhat.com>
|
|
||||||
Signed-off-by: Juan Quintela <quintela@redhat.com>
|
|
||||||
Signed-off-by: Aichun Shi <aichun.shi@intel.com>
|
|
||||||
---
|
|
||||||
meson.build | 17 +++++
|
|
||||||
meson_options.txt | 2 +
|
|
||||||
migration/ram.c | 34 +++++++++-
|
|
||||||
migration/xbzrle.c | 124 ++++++++++++++++++++++++++++++++++
|
|
||||||
migration/xbzrle.h | 4 ++
|
|
||||||
scripts/meson-buildoptions.sh | 3 +
|
|
||||||
6 files changed, 181 insertions(+), 3 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/meson.build b/meson.build
|
|
||||||
index 9f77254861..45bc69bf0c 100644
|
|
||||||
--- a/meson.build
|
|
||||||
+++ b/meson.build
|
|
||||||
@@ -1816,6 +1816,22 @@ config_host_data.set('CONFIG_AF_VSOCK', cc.compiles(gnu_source_prefix + '''
|
|
||||||
return -1;
|
|
||||||
}'''))
|
|
||||||
|
|
||||||
+config_host_data.set('CONFIG_AVX512BW_OPT', get_option('avx512bw') \
|
|
||||||
+ .require(have_cpuid_h, error_message: 'cpuid.h not available, cannot enable AVX512BW') \
|
|
||||||
+ .require(cc.links('''
|
|
||||||
+ #pragma GCC push_options
|
|
||||||
+ #pragma GCC target("avx512bw")
|
|
||||||
+ #include <cpuid.h>
|
|
||||||
+ #include <immintrin.h>
|
|
||||||
+ static int bar(void *a) {
|
|
||||||
+
|
|
||||||
+ __m512i *x = a;
|
|
||||||
+ __m512i res= _mm512_abs_epi8(*x);
|
|
||||||
+ return res[1];
|
|
||||||
+ }
|
|
||||||
+ int main(int argc, char *argv[]) { return bar(argv[0]); }
|
|
||||||
+ '''), error_message: 'AVX512BW not available').allowed())
|
|
||||||
+
|
|
||||||
ignored = ['CONFIG_QEMU_INTERP_PREFIX', # actually per-target
|
|
||||||
'HAVE_GDB_BIN']
|
|
||||||
arrays = ['CONFIG_BDRV_RW_WHITELIST', 'CONFIG_BDRV_RO_WHITELIST']
|
|
||||||
@@ -3318,6 +3334,7 @@ summary_info += {'debug stack usage': config_host.has_key('CONFIG_DEBUG_STACK_US
|
|
||||||
summary_info += {'mutex debugging': config_host.has_key('CONFIG_DEBUG_MUTEX')}
|
|
||||||
summary_info += {'memory allocator': get_option('malloc')}
|
|
||||||
summary_info += {'avx2 optimization': config_host_data.get('CONFIG_AVX2_OPT')}
|
|
||||||
+summary_info += {'avx512bw optimization': config_host_data.get('CONFIG_AVX512BW_OPT')}
|
|
||||||
summary_info += {'avx512f optimization': config_host_data.get('CONFIG_AVX512F_OPT')}
|
|
||||||
summary_info += {'gprof enabled': config_host.has_key('CONFIG_GPROF')}
|
|
||||||
summary_info += {'gcov': get_option('b_coverage')}
|
|
||||||
diff --git a/meson_options.txt b/meson_options.txt
|
|
||||||
index e9cbe48cb9..ec9c3c0a05 100644
|
|
||||||
--- a/meson_options.txt
|
|
||||||
+++ b/meson_options.txt
|
|
||||||
@@ -70,6 +70,8 @@ option('avx2', type: 'feature', value: 'auto',
|
|
||||||
description: 'AVX2 optimizations')
|
|
||||||
option('avx512f', type: 'feature', value: 'disabled',
|
|
||||||
description: 'AVX512F optimizations')
|
|
||||||
+option('avx512bw', type: 'feature', value: 'auto',
|
|
||||||
+ description: 'AVX512BW optimizations')
|
|
||||||
|
|
||||||
option('attr', type : 'feature', value : 'auto',
|
|
||||||
description: 'attr/xattr support')
|
|
||||||
diff --git a/migration/ram.c b/migration/ram.c
|
|
||||||
index c3484ee1a9..a4383954b4 100644
|
|
||||||
--- a/migration/ram.c
|
|
||||||
+++ b/migration/ram.c
|
|
||||||
@@ -91,6 +91,34 @@ static inline bool is_zero_range(uint8_t *p, uint64_t size)
|
|
||||||
return buffer_is_zero(p, size);
|
|
||||||
}
|
|
||||||
|
|
||||||
+int (*xbzrle_encode_buffer_func)(uint8_t *, uint8_t *, int,
|
|
||||||
+ uint8_t *, int) = xbzrle_encode_buffer;
|
|
||||||
+#if defined(CONFIG_AVX512BW_OPT)
|
|
||||||
+#include "qemu/cpuid.h"
|
|
||||||
+static void __attribute__((constructor)) init_cpu_flag(void)
|
|
||||||
+{
|
|
||||||
+ unsigned max = __get_cpuid_max(0, NULL);
|
|
||||||
+ int a, b, c, d;
|
|
||||||
+ if (max >= 1) {
|
|
||||||
+ __cpuid(1, a, b, c, d);
|
|
||||||
+ /* We must check that AVX is not just available, but usable. */
|
|
||||||
+ if ((c & bit_OSXSAVE) && (c & bit_AVX) && max >= 7) {
|
|
||||||
+ int bv;
|
|
||||||
+ __asm("xgetbv" : "=a"(bv), "=d"(d) : "c"(0));
|
|
||||||
+ __cpuid_count(7, 0, a, b, c, d);
|
|
||||||
+ /* 0xe6:
|
|
||||||
+ * XCR0[7:5] = 111b (OPMASK state, upper 256-bit of ZMM0-ZMM15
|
|
||||||
+ * and ZMM16-ZMM31 state are enabled by OS)
|
|
||||||
+ * XCR0[2:1] = 11b (XMM state and YMM state are enabled by OS)
|
|
||||||
+ */
|
|
||||||
+ if ((bv & 0xe6) == 0xe6 && (b & bit_AVX512BW)) {
|
|
||||||
+ xbzrle_encode_buffer_func = xbzrle_encode_buffer_avx512;
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+}
|
|
||||||
+#endif
|
|
||||||
+
|
|
||||||
XBZRLECacheStats xbzrle_counters;
|
|
||||||
|
|
||||||
/* struct contains XBZRLE cache and a static page
|
|
||||||
@@ -1031,9 +1059,9 @@ static int save_xbzrle_page(RAMState *rs, uint8_t **current_data,
|
|
||||||
memcpy(XBZRLE.current_buf, *current_data, TARGET_PAGE_SIZE);
|
|
||||||
|
|
||||||
/* XBZRLE encoding (if there is no overflow) */
|
|
||||||
- encoded_len = xbzrle_encode_buffer(prev_cached_page, XBZRLE.current_buf,
|
|
||||||
- TARGET_PAGE_SIZE, XBZRLE.encoded_buf,
|
|
||||||
- TARGET_PAGE_SIZE);
|
|
||||||
+ encoded_len = xbzrle_encode_buffer_func(prev_cached_page, XBZRLE.current_buf,
|
|
||||||
+ TARGET_PAGE_SIZE, XBZRLE.encoded_buf,
|
|
||||||
+ TARGET_PAGE_SIZE);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Update the cache contents, so that it corresponds to the data
|
|
||||||
diff --git a/migration/xbzrle.c b/migration/xbzrle.c
|
|
||||||
index 1ba482ded9..05366e86c0 100644
|
|
||||||
--- a/migration/xbzrle.c
|
|
||||||
+++ b/migration/xbzrle.c
|
|
||||||
@@ -174,3 +174,127 @@ int xbzrle_decode_buffer(uint8_t *src, int slen, uint8_t *dst, int dlen)
|
|
||||||
|
|
||||||
return d;
|
|
||||||
}
|
|
||||||
+
|
|
||||||
+#if defined(CONFIG_AVX512BW_OPT)
|
|
||||||
+#pragma GCC push_options
|
|
||||||
+#pragma GCC target("avx512bw")
|
|
||||||
+#include <immintrin.h>
|
|
||||||
+int xbzrle_encode_buffer_avx512(uint8_t *old_buf, uint8_t *new_buf, int slen,
|
|
||||||
+ uint8_t *dst, int dlen)
|
|
||||||
+{
|
|
||||||
+ uint32_t zrun_len = 0, nzrun_len = 0;
|
|
||||||
+ int d = 0, i = 0, num = 0;
|
|
||||||
+ uint8_t *nzrun_start = NULL;
|
|
||||||
+ /* add 1 to include residual part in main loop */
|
|
||||||
+ uint32_t count512s = (slen >> 6) + 1;
|
|
||||||
+ /* countResidual is tail of data, i.e., countResidual = slen % 64 */
|
|
||||||
+ uint32_t count_residual = slen & 0b111111;
|
|
||||||
+ bool never_same = true;
|
|
||||||
+ uint64_t mask_residual = 1;
|
|
||||||
+ mask_residual <<= count_residual;
|
|
||||||
+ mask_residual -= 1;
|
|
||||||
+ __m512i r = _mm512_set1_epi32(0);
|
|
||||||
+
|
|
||||||
+ while (count512s) {
|
|
||||||
+ if (d + 2 > dlen) {
|
|
||||||
+ return -1;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ int bytes_to_check = 64;
|
|
||||||
+ uint64_t mask = 0xffffffffffffffff;
|
|
||||||
+ if (count512s == 1) {
|
|
||||||
+ bytes_to_check = count_residual;
|
|
||||||
+ mask = mask_residual;
|
|
||||||
+ }
|
|
||||||
+ __m512i old_data = _mm512_mask_loadu_epi8(r,
|
|
||||||
+ mask, old_buf + i);
|
|
||||||
+ __m512i new_data = _mm512_mask_loadu_epi8(r,
|
|
||||||
+ mask, new_buf + i);
|
|
||||||
+ uint64_t comp = _mm512_cmpeq_epi8_mask(old_data, new_data);
|
|
||||||
+ count512s--;
|
|
||||||
+
|
|
||||||
+ bool is_same = (comp & 0x1);
|
|
||||||
+ while (bytes_to_check) {
|
|
||||||
+ if (is_same) {
|
|
||||||
+ if (nzrun_len) {
|
|
||||||
+ d += uleb128_encode_small(dst + d, nzrun_len);
|
|
||||||
+ if (d + nzrun_len > dlen) {
|
|
||||||
+ return -1;
|
|
||||||
+ }
|
|
||||||
+ nzrun_start = new_buf + i - nzrun_len;
|
|
||||||
+ memcpy(dst + d, nzrun_start, nzrun_len);
|
|
||||||
+ d += nzrun_len;
|
|
||||||
+ nzrun_len = 0;
|
|
||||||
+ }
|
|
||||||
+ /* 64 data at a time for speed */
|
|
||||||
+ if (count512s && (comp == 0xffffffffffffffff)) {
|
|
||||||
+ i += 64;
|
|
||||||
+ zrun_len += 64;
|
|
||||||
+ break;
|
|
||||||
+ }
|
|
||||||
+ never_same = false;
|
|
||||||
+ num = __builtin_ctzll(~comp);
|
|
||||||
+ num = (num < bytes_to_check) ? num : bytes_to_check;
|
|
||||||
+ zrun_len += num;
|
|
||||||
+ bytes_to_check -= num;
|
|
||||||
+ comp >>= num;
|
|
||||||
+ i += num;
|
|
||||||
+ if (bytes_to_check) {
|
|
||||||
+ /* still has different data after same data */
|
|
||||||
+ d += uleb128_encode_small(dst + d, zrun_len);
|
|
||||||
+ zrun_len = 0;
|
|
||||||
+ } else {
|
|
||||||
+ break;
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+ if (never_same || zrun_len) {
|
|
||||||
+ /*
|
|
||||||
+ * never_same only acts if
|
|
||||||
+ * data begins with diff in first count512s
|
|
||||||
+ */
|
|
||||||
+ d += uleb128_encode_small(dst + d, zrun_len);
|
|
||||||
+ zrun_len = 0;
|
|
||||||
+ never_same = false;
|
|
||||||
+ }
|
|
||||||
+ /* has diff, 64 data at a time for speed */
|
|
||||||
+ if ((bytes_to_check == 64) && (comp == 0x0)) {
|
|
||||||
+ i += 64;
|
|
||||||
+ nzrun_len += 64;
|
|
||||||
+ break;
|
|
||||||
+ }
|
|
||||||
+ num = __builtin_ctzll(comp);
|
|
||||||
+ num = (num < bytes_to_check) ? num : bytes_to_check;
|
|
||||||
+ nzrun_len += num;
|
|
||||||
+ bytes_to_check -= num;
|
|
||||||
+ comp >>= num;
|
|
||||||
+ i += num;
|
|
||||||
+ if (bytes_to_check) {
|
|
||||||
+ /* mask like 111000 */
|
|
||||||
+ d += uleb128_encode_small(dst + d, nzrun_len);
|
|
||||||
+ /* overflow */
|
|
||||||
+ if (d + nzrun_len > dlen) {
|
|
||||||
+ return -1;
|
|
||||||
+ }
|
|
||||||
+ nzrun_start = new_buf + i - nzrun_len;
|
|
||||||
+ memcpy(dst + d, nzrun_start, nzrun_len);
|
|
||||||
+ d += nzrun_len;
|
|
||||||
+ nzrun_len = 0;
|
|
||||||
+ is_same = true;
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ if (nzrun_len != 0) {
|
|
||||||
+ d += uleb128_encode_small(dst + d, nzrun_len);
|
|
||||||
+ /* overflow */
|
|
||||||
+ if (d + nzrun_len > dlen) {
|
|
||||||
+ return -1;
|
|
||||||
+ }
|
|
||||||
+ nzrun_start = new_buf + i - nzrun_len;
|
|
||||||
+ memcpy(dst + d, nzrun_start, nzrun_len);
|
|
||||||
+ d += nzrun_len;
|
|
||||||
+ }
|
|
||||||
+ return d;
|
|
||||||
+}
|
|
||||||
+#pragma GCC pop_options
|
|
||||||
+#endif
|
|
||||||
diff --git a/migration/xbzrle.h b/migration/xbzrle.h
|
|
||||||
index a0db507b9c..6feb49160a 100644
|
|
||||||
--- a/migration/xbzrle.h
|
|
||||||
+++ b/migration/xbzrle.h
|
|
||||||
@@ -18,4 +18,8 @@ int xbzrle_encode_buffer(uint8_t *old_buf, uint8_t *new_buf, int slen,
|
|
||||||
uint8_t *dst, int dlen);
|
|
||||||
|
|
||||||
int xbzrle_decode_buffer(uint8_t *src, int slen, uint8_t *dst, int dlen);
|
|
||||||
+#if defined(CONFIG_AVX512BW_OPT)
|
|
||||||
+int xbzrle_encode_buffer_avx512(uint8_t *old_buf, uint8_t *new_buf, int slen,
|
|
||||||
+ uint8_t *dst, int dlen);
|
|
||||||
+#endif
|
|
||||||
#endif
|
|
||||||
diff --git a/scripts/meson-buildoptions.sh b/scripts/meson-buildoptions.sh
|
|
||||||
index b994bf16f0..8c00cce411 100644
|
|
||||||
--- a/scripts/meson-buildoptions.sh
|
|
||||||
+++ b/scripts/meson-buildoptions.sh
|
|
||||||
@@ -26,6 +26,7 @@ meson_options_help() {
|
|
||||||
printf "%s\n" ' attr attr/xattr support'
|
|
||||||
printf "%s\n" ' auth-pam PAM access control'
|
|
||||||
printf "%s\n" ' avx2 AVX2 optimizations'
|
|
||||||
+ printf "%s\n" ' avx512bw AVX512BW optimizations'
|
|
||||||
printf "%s\n" ' avx512f AVX512F optimizations'
|
|
||||||
printf "%s\n" ' bpf eBPF support'
|
|
||||||
printf "%s\n" ' brlapi brlapi character device driver'
|
|
||||||
@@ -111,6 +112,8 @@ _meson_option_parse() {
|
|
||||||
--disable-auth-pam) printf "%s" -Dauth_pam=disabled ;;
|
|
||||||
--enable-avx2) printf "%s" -Davx2=enabled ;;
|
|
||||||
--disable-avx2) printf "%s" -Davx2=disabled ;;
|
|
||||||
+ --enable-avx512bw) printf "%s" -Davx512bw=enabled ;;
|
|
||||||
+ --disable-avx512bw) printf "%s" -Davx512bw=disabled ;;
|
|
||||||
--enable-avx512f) printf "%s" -Davx512f=enabled ;;
|
|
||||||
--disable-avx512f) printf "%s" -Davx512f=disabled ;;
|
|
||||||
--enable-bpf) printf "%s" -Dbpf=enabled ;;
|
|
||||||
--
|
|
||||||
2.27.0
|
|
||||||
|
|
||||||
@ -1,758 +0,0 @@
|
|||||||
From 1fc8fa6cd621c17988b043c1b3abe9ccb189a1d7 Mon Sep 17 00:00:00 2001
|
|
||||||
From: lixianglai <lixianglai@loongson.cn>
|
|
||||||
Date: Tue, 7 Feb 2023 06:34:32 -0500
|
|
||||||
Subject: [PATCH] Add PowerManager support.
|
|
||||||
|
|
||||||
Add Loongarch ACPI power management device simulation.
|
|
||||||
|
|
||||||
Signed-off-by: lixianglai <lixianglai@loongson.cn>
|
|
||||||
---
|
|
||||||
hw/acpi/Kconfig | 8 +
|
|
||||||
hw/acpi/larch_7a.c | 616 +++++++++++++++++++++++++++++++++++++++++
|
|
||||||
hw/acpi/meson.build | 1 +
|
|
||||||
include/hw/acpi/ls7a.h | 79 ++++++
|
|
||||||
4 files changed, 704 insertions(+)
|
|
||||||
create mode 100644 hw/acpi/larch_7a.c
|
|
||||||
create mode 100644 include/hw/acpi/ls7a.h
|
|
||||||
|
|
||||||
diff --git a/hw/acpi/Kconfig b/hw/acpi/Kconfig
|
|
||||||
index 622b0b50b7..245c5554df 100644
|
|
||||||
--- a/hw/acpi/Kconfig
|
|
||||||
+++ b/hw/acpi/Kconfig
|
|
||||||
@@ -15,6 +15,14 @@ config ACPI_X86_ICH
|
|
||||||
bool
|
|
||||||
select ACPI_X86
|
|
||||||
|
|
||||||
+config ACPI_LOONGARCH
|
|
||||||
+ bool
|
|
||||||
+ select ACPI
|
|
||||||
+ select ACPI_CPU_HOTPLUG
|
|
||||||
+ select ACPI_MEMORY_HOTPLUG
|
|
||||||
+ select ACPI_PIIX4
|
|
||||||
+ select ACPI_PCIHP
|
|
||||||
+
|
|
||||||
config ACPI_CPU_HOTPLUG
|
|
||||||
bool
|
|
||||||
|
|
||||||
diff --git a/hw/acpi/larch_7a.c b/hw/acpi/larch_7a.c
|
|
||||||
new file mode 100644
|
|
||||||
index 0000000000..59b43170ff
|
|
||||||
--- /dev/null
|
|
||||||
+++ b/hw/acpi/larch_7a.c
|
|
||||||
@@ -0,0 +1,616 @@
|
|
||||||
+/*
|
|
||||||
+ * Loongarch acpi emulation
|
|
||||||
+ *
|
|
||||||
+ * Copyright (c) 2023 Loongarch Technology
|
|
||||||
+ *
|
|
||||||
+ * This program is free software; you can redistribute it and/or modify it
|
|
||||||
+ * under the terms and conditions of the GNU General Public License,
|
|
||||||
+ * version 2 or later, as published by the Free Software Foundation.
|
|
||||||
+ *
|
|
||||||
+ * This program is distributed in the hope it will be useful, but WITHOUT
|
|
||||||
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
||||||
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
||||||
+ * more details.
|
|
||||||
+ *
|
|
||||||
+ * You should have received a copy of the GNU General Public License along with
|
|
||||||
+ * this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
+ */
|
|
||||||
+
|
|
||||||
+#include "qemu/osdep.h"
|
|
||||||
+#include "sysemu/sysemu.h"
|
|
||||||
+#include "sysemu/runstate.h"
|
|
||||||
+#include "sysemu/reset.h"
|
|
||||||
+#include "hw/hw.h"
|
|
||||||
+#include "hw/irq.h"
|
|
||||||
+#include "hw/acpi/acpi.h"
|
|
||||||
+#include "hw/acpi/ls7a.h"
|
|
||||||
+#include "hw/nvram/fw_cfg.h"
|
|
||||||
+#include "qemu/config-file.h"
|
|
||||||
+#include "qapi/opts-visitor.h"
|
|
||||||
+#include "qapi/qapi-events-run-state.h"
|
|
||||||
+#include "qapi/error.h"
|
|
||||||
+#include "hw/loongarch/ls7a.h"
|
|
||||||
+#include "hw/mem/pc-dimm.h"
|
|
||||||
+#include "hw/mem/nvdimm.h"
|
|
||||||
+#include "migration/vmstate.h"
|
|
||||||
+
|
|
||||||
+static void ls7a_pm_update_sci_fn(ACPIREGS *regs)
|
|
||||||
+{
|
|
||||||
+ LS7APCIPMRegs *pm = container_of(regs, LS7APCIPMRegs, acpi_regs);
|
|
||||||
+ acpi_update_sci(&pm->acpi_regs, pm->irq);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+static uint64_t ls7a_gpe_readb(void *opaque, hwaddr addr, unsigned width)
|
|
||||||
+{
|
|
||||||
+ LS7APCIPMRegs *pm = opaque;
|
|
||||||
+ return acpi_gpe_ioport_readb(&pm->acpi_regs, addr);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+static void ls7a_gpe_writeb(void *opaque, hwaddr addr, uint64_t val,
|
|
||||||
+ unsigned width)
|
|
||||||
+{
|
|
||||||
+ LS7APCIPMRegs *pm = opaque;
|
|
||||||
+ acpi_gpe_ioport_writeb(&pm->acpi_regs, addr, val);
|
|
||||||
+ acpi_update_sci(&pm->acpi_regs, pm->irq);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+static const MemoryRegionOps ls7a_gpe_ops = {
|
|
||||||
+ .read = ls7a_gpe_readb,
|
|
||||||
+ .write = ls7a_gpe_writeb,
|
|
||||||
+ .valid.min_access_size = 1,
|
|
||||||
+ .valid.max_access_size = 8,
|
|
||||||
+ .impl.min_access_size = 1,
|
|
||||||
+ .impl.max_access_size = 1,
|
|
||||||
+ .endianness = DEVICE_LITTLE_ENDIAN,
|
|
||||||
+};
|
|
||||||
+
|
|
||||||
+#define VMSTATE_GPE_ARRAY(_field, _state) \
|
|
||||||
+{ \
|
|
||||||
+ .name = (stringify(_field)), .version_id = 0, .num = ACPI_GPE0_LEN, \
|
|
||||||
+ .info = &vmstate_info_uint8, .size = sizeof(uint8_t), \
|
|
||||||
+ .flags = VMS_ARRAY | VMS_POINTER, \
|
|
||||||
+ .offset = vmstate_offset_pointer(_state, _field, uint8_t), \
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+static uint64_t ls7a_reset_readw(void *opaque, hwaddr addr, unsigned width)
|
|
||||||
+{
|
|
||||||
+ return 0;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+static void ls7a_reset_writew(void *opaque, hwaddr addr, uint64_t val,
|
|
||||||
+ unsigned width)
|
|
||||||
+{
|
|
||||||
+ if (val & 1) {
|
|
||||||
+ qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET);
|
|
||||||
+ }
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+static const MemoryRegionOps ls7a_reset_ops = {
|
|
||||||
+ .read = ls7a_reset_readw,
|
|
||||||
+ .write = ls7a_reset_writew,
|
|
||||||
+ .valid.min_access_size = 4,
|
|
||||||
+ .valid.max_access_size = 4,
|
|
||||||
+ .endianness = DEVICE_LITTLE_ENDIAN,
|
|
||||||
+};
|
|
||||||
+
|
|
||||||
+static bool vmstate_test_use_memhp(void *opaque)
|
|
||||||
+{
|
|
||||||
+ LS7APCIPMRegs *s = opaque;
|
|
||||||
+ return s->acpi_memory_hotplug.is_enabled;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+static const VMStateDescription vmstate_memhp_state = {
|
|
||||||
+ .name = "ls7a_pm/memhp",
|
|
||||||
+ .version_id = 1,
|
|
||||||
+ .minimum_version_id = 1,
|
|
||||||
+ .minimum_version_id_old = 1,
|
|
||||||
+ .needed = vmstate_test_use_memhp,
|
|
||||||
+ .fields = (VMStateField[]){ VMSTATE_MEMORY_HOTPLUG(acpi_memory_hotplug,
|
|
||||||
+ LS7APCIPMRegs),
|
|
||||||
+ VMSTATE_END_OF_LIST() }
|
|
||||||
+};
|
|
||||||
+
|
|
||||||
+static const VMStateDescription vmstate_cpuhp_state = {
|
|
||||||
+ .name = "ls7a_pm/cpuhp",
|
|
||||||
+ .version_id = 1,
|
|
||||||
+ .minimum_version_id = 1,
|
|
||||||
+ .minimum_version_id_old = 1,
|
|
||||||
+ .fields =
|
|
||||||
+ (VMStateField[]){ VMSTATE_CPU_HOTPLUG(cpuhp_state, LS7APCIPMRegs),
|
|
||||||
+ VMSTATE_END_OF_LIST() }
|
|
||||||
+};
|
|
||||||
+
|
|
||||||
+const VMStateDescription vmstate_ls7a_pm = {
|
|
||||||
+ .name = "ls7a_pm",
|
|
||||||
+ .version_id = 1,
|
|
||||||
+ .minimum_version_id = 1,
|
|
||||||
+ .fields =
|
|
||||||
+ (VMStateField[]){
|
|
||||||
+ VMSTATE_UINT16(acpi_regs.pm1.evt.sts, LS7APCIPMRegs),
|
|
||||||
+ VMSTATE_UINT16(acpi_regs.pm1.evt.en, LS7APCIPMRegs),
|
|
||||||
+ VMSTATE_UINT16(acpi_regs.pm1.cnt.cnt, LS7APCIPMRegs),
|
|
||||||
+ VMSTATE_TIMER_PTR(acpi_regs.tmr.timer, LS7APCIPMRegs),
|
|
||||||
+ VMSTATE_INT64(acpi_regs.tmr.overflow_time, LS7APCIPMRegs),
|
|
||||||
+ VMSTATE_GPE_ARRAY(acpi_regs.gpe.sts, LS7APCIPMRegs),
|
|
||||||
+ VMSTATE_GPE_ARRAY(acpi_regs.gpe.en, LS7APCIPMRegs),
|
|
||||||
+ VMSTATE_END_OF_LIST() },
|
|
||||||
+ .subsections = (const VMStateDescription *[]){ &vmstate_memhp_state,
|
|
||||||
+ &vmstate_cpuhp_state, NULL }
|
|
||||||
+};
|
|
||||||
+
|
|
||||||
+static inline int64_t acpi_pm_tmr_get_clock(void)
|
|
||||||
+{
|
|
||||||
+ return muldiv64(qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL), PM_TIMER_FREQUENCY,
|
|
||||||
+ NANOSECONDS_PER_SECOND);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+static uint32_t acpi_pm_tmr_get(ACPIREGS *ar)
|
|
||||||
+{
|
|
||||||
+ uint32_t d = acpi_pm_tmr_get_clock();
|
|
||||||
+ return d & 0xffffff;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+static void acpi_pm_tmr_timer(void *opaque)
|
|
||||||
+{
|
|
||||||
+ ACPIREGS *ar = opaque;
|
|
||||||
+ qemu_system_wakeup_request(QEMU_WAKEUP_REASON_PMTIMER, NULL);
|
|
||||||
+ ar->tmr.update_sci(ar);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+static uint64_t acpi_pm_tmr_read(void *opaque, hwaddr addr, unsigned width)
|
|
||||||
+{
|
|
||||||
+ return acpi_pm_tmr_get(opaque);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+static void acpi_pm_tmr_write(void *opaque, hwaddr addr, uint64_t val,
|
|
||||||
+ unsigned width)
|
|
||||||
+{
|
|
||||||
+ /* nothing */
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+static const MemoryRegionOps acpi_pm_tmr_ops = {
|
|
||||||
+ .read = acpi_pm_tmr_read,
|
|
||||||
+ .write = acpi_pm_tmr_write,
|
|
||||||
+ .valid.min_access_size = 4,
|
|
||||||
+ .valid.max_access_size = 4,
|
|
||||||
+ .endianness = DEVICE_LITTLE_ENDIAN,
|
|
||||||
+};
|
|
||||||
+
|
|
||||||
+static void ls7a_pm_tmr_init(ACPIREGS *ar, acpi_update_sci_fn update_sci,
|
|
||||||
+ MemoryRegion *parent, uint64_t offset)
|
|
||||||
+{
|
|
||||||
+ ar->tmr.update_sci = update_sci;
|
|
||||||
+ ar->tmr.timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, acpi_pm_tmr_timer, ar);
|
|
||||||
+ memory_region_init_io(&ar->tmr.io, memory_region_owner(parent),
|
|
||||||
+ &acpi_pm_tmr_ops, ar, "acpi-tmr", 4);
|
|
||||||
+ memory_region_add_subregion(parent, offset, &ar->tmr.io);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+static void acpi_pm1_evt_write_sts(ACPIREGS *ar, uint16_t val)
|
|
||||||
+{
|
|
||||||
+ uint16_t pm1_sts = acpi_pm1_evt_get_sts(ar);
|
|
||||||
+ if (pm1_sts & val & ACPI_BITMASK_TIMER_STATUS) {
|
|
||||||
+ /* if TMRSTS is reset, then compute the new overflow time */
|
|
||||||
+ acpi_pm_tmr_calc_overflow_time(ar);
|
|
||||||
+ }
|
|
||||||
+ ar->pm1.evt.sts &= ~val;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+static uint64_t acpi_pm_evt_read(void *opaque, hwaddr addr, unsigned width)
|
|
||||||
+{
|
|
||||||
+ ACPIREGS *ar = opaque;
|
|
||||||
+ switch (addr) {
|
|
||||||
+ case 0:
|
|
||||||
+ return acpi_pm1_evt_get_sts(ar);
|
|
||||||
+ case 4:
|
|
||||||
+ return ar->pm1.evt.en;
|
|
||||||
+ default:
|
|
||||||
+ return 0;
|
|
||||||
+ }
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+static void acpi_pm1_evt_write_en(ACPIREGS *ar, uint16_t val)
|
|
||||||
+{
|
|
||||||
+ ar->pm1.evt.en = val;
|
|
||||||
+ qemu_system_wakeup_enable(QEMU_WAKEUP_REASON_RTC,
|
|
||||||
+ val & ACPI_BITMASK_RT_CLOCK_ENABLE);
|
|
||||||
+ qemu_system_wakeup_enable(QEMU_WAKEUP_REASON_PMTIMER,
|
|
||||||
+ val & ACPI_BITMASK_TIMER_ENABLE);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+static void acpi_pm_evt_write(void *opaque, hwaddr addr, uint64_t val,
|
|
||||||
+ unsigned width)
|
|
||||||
+{
|
|
||||||
+ ACPIREGS *ar = opaque;
|
|
||||||
+ switch (addr) {
|
|
||||||
+ case 0:
|
|
||||||
+ acpi_pm1_evt_write_sts(ar, val);
|
|
||||||
+ ar->pm1.evt.update_sci(ar);
|
|
||||||
+ break;
|
|
||||||
+ case 4:
|
|
||||||
+ acpi_pm1_evt_write_en(ar, val);
|
|
||||||
+ ar->pm1.evt.update_sci(ar);
|
|
||||||
+ break;
|
|
||||||
+ default:
|
|
||||||
+ break;
|
|
||||||
+ }
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+static const MemoryRegionOps acpi_pm_evt_ops = {
|
|
||||||
+ .read = acpi_pm_evt_read,
|
|
||||||
+ .write = acpi_pm_evt_write,
|
|
||||||
+ .valid.min_access_size = 4,
|
|
||||||
+ .valid.max_access_size = 4,
|
|
||||||
+ .endianness = DEVICE_LITTLE_ENDIAN,
|
|
||||||
+};
|
|
||||||
+
|
|
||||||
+static void ls7a_pm1_evt_init(ACPIREGS *ar, acpi_update_sci_fn update_sci,
|
|
||||||
+ MemoryRegion *parent, uint64_t offset)
|
|
||||||
+{
|
|
||||||
+ ar->pm1.evt.update_sci = update_sci;
|
|
||||||
+ memory_region_init_io(&ar->pm1.evt.io, memory_region_owner(parent),
|
|
||||||
+ &acpi_pm_evt_ops, ar, "acpi-evt", 8);
|
|
||||||
+ memory_region_add_subregion(parent, offset, &ar->pm1.evt.io);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+static uint64_t acpi_pm_cnt_read(void *opaque, hwaddr addr, unsigned width)
|
|
||||||
+{
|
|
||||||
+ ACPIREGS *ar = opaque;
|
|
||||||
+ return ar->pm1.cnt.cnt;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+/* ACPI PM1aCNT */
|
|
||||||
+static void acpi_pm1_cnt_write(ACPIREGS *ar, uint16_t val)
|
|
||||||
+{
|
|
||||||
+ ar->pm1.cnt.cnt = val & ~(ACPI_BITMASK_SLEEP_ENABLE);
|
|
||||||
+ if (val & ACPI_BITMASK_SLEEP_ENABLE) {
|
|
||||||
+ /* change suspend type */
|
|
||||||
+ uint16_t sus_typ = (val >> 10) & 7;
|
|
||||||
+ switch (sus_typ) {
|
|
||||||
+ /* s3,s4 not support */
|
|
||||||
+ case 5:
|
|
||||||
+ case 6:
|
|
||||||
+ warn_report("acpi s3,s4 state not support");
|
|
||||||
+ break;
|
|
||||||
+ /* s5: soft off */
|
|
||||||
+ case 7:
|
|
||||||
+ qemu_system_shutdown_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN);
|
|
||||||
+ break;
|
|
||||||
+ default:
|
|
||||||
+ break;
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+static void acpi_pm_cnt_write(void *opaque, hwaddr addr, uint64_t val,
|
|
||||||
+ unsigned width)
|
|
||||||
+{
|
|
||||||
+ acpi_pm1_cnt_write(opaque, val);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+static const MemoryRegionOps acpi_pm_cnt_ops = {
|
|
||||||
+ .read = acpi_pm_cnt_read,
|
|
||||||
+ .write = acpi_pm_cnt_write,
|
|
||||||
+ .valid.min_access_size = 4,
|
|
||||||
+ .valid.max_access_size = 4,
|
|
||||||
+ .endianness = DEVICE_LITTLE_ENDIAN,
|
|
||||||
+};
|
|
||||||
+
|
|
||||||
+static void acpi_notify_wakeup(Notifier *notifier, void *data)
|
|
||||||
+{
|
|
||||||
+ ACPIREGS *ar = container_of(notifier, ACPIREGS, wakeup);
|
|
||||||
+ WakeupReason *reason = data;
|
|
||||||
+
|
|
||||||
+ switch (*reason) {
|
|
||||||
+ case QEMU_WAKEUP_REASON_RTC:
|
|
||||||
+ ar->pm1.evt.sts |=
|
|
||||||
+ (ACPI_BITMASK_WAKE_STATUS | ACPI_BITMASK_RT_CLOCK_STATUS);
|
|
||||||
+ break;
|
|
||||||
+ case QEMU_WAKEUP_REASON_PMTIMER:
|
|
||||||
+ ar->pm1.evt.sts |=
|
|
||||||
+ (ACPI_BITMASK_WAKE_STATUS | ACPI_BITMASK_TIMER_STATUS);
|
|
||||||
+ break;
|
|
||||||
+ case QEMU_WAKEUP_REASON_OTHER:
|
|
||||||
+ /*
|
|
||||||
+ * ACPI_BITMASK_WAKE_STATUS should be set on resume.
|
|
||||||
+ * Pretend that resume was caused by power button
|
|
||||||
+ */
|
|
||||||
+ ar->pm1.evt.sts |=
|
|
||||||
+ (ACPI_BITMASK_WAKE_STATUS | ACPI_BITMASK_POWER_BUTTON_STATUS);
|
|
||||||
+ break;
|
|
||||||
+ default:
|
|
||||||
+ break;
|
|
||||||
+ }
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+static void ls7a_pm1_cnt_init(ACPIREGS *ar, MemoryRegion *parent,
|
|
||||||
+ bool disable_s3, bool disable_s4, uint8_t s4_val,
|
|
||||||
+ uint64_t offset)
|
|
||||||
+{
|
|
||||||
+ FWCfgState *fw_cfg;
|
|
||||||
+
|
|
||||||
+ ar->pm1.cnt.s4_val = s4_val;
|
|
||||||
+ ar->wakeup.notify = acpi_notify_wakeup;
|
|
||||||
+ qemu_register_wakeup_notifier(&ar->wakeup);
|
|
||||||
+ memory_region_init_io(&ar->pm1.cnt.io, memory_region_owner(parent),
|
|
||||||
+ &acpi_pm_cnt_ops, ar, "acpi-cnt", 4);
|
|
||||||
+ memory_region_add_subregion(parent, offset, &ar->pm1.cnt.io);
|
|
||||||
+
|
|
||||||
+ fw_cfg = fw_cfg_find();
|
|
||||||
+ if (fw_cfg) {
|
|
||||||
+ uint8_t suspend[6] = { 128, 0, 0, 129, 128, 128 };
|
|
||||||
+ suspend[3] = 1 | ((!disable_s3) << 7);
|
|
||||||
+ suspend[4] = s4_val | ((!disable_s4) << 7);
|
|
||||||
+ fw_cfg_add_file(fw_cfg, "etc/system-states", g_memdup(suspend, 6), 6);
|
|
||||||
+ }
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+static void ls7a_pm_reset(void *opaque)
|
|
||||||
+{
|
|
||||||
+ LS7APCIPMRegs *pm = opaque;
|
|
||||||
+
|
|
||||||
+ acpi_pm1_evt_reset(&pm->acpi_regs);
|
|
||||||
+ acpi_pm1_cnt_reset(&pm->acpi_regs);
|
|
||||||
+ acpi_pm_tmr_reset(&pm->acpi_regs);
|
|
||||||
+ acpi_gpe_reset(&pm->acpi_regs);
|
|
||||||
+
|
|
||||||
+ acpi_update_sci(&pm->acpi_regs, pm->irq);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+static void pm_powerdown_req(Notifier *n, void *opaque)
|
|
||||||
+{
|
|
||||||
+ LS7APCIPMRegs *pm = container_of(n, LS7APCIPMRegs, powerdown_notifier);
|
|
||||||
+
|
|
||||||
+ acpi_pm1_evt_power_down(&pm->acpi_regs);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+void ls7a_pm_init(LS7APCIPMRegs *pm, qemu_irq *pic)
|
|
||||||
+{
|
|
||||||
+ unsigned long base, gpe_len, acpi_aci_irq;
|
|
||||||
+
|
|
||||||
+ /*
|
|
||||||
+ * ls7a board acpi hardware info, including
|
|
||||||
+ * acpi system io base address
|
|
||||||
+ * acpi gpe length
|
|
||||||
+ * acpi sci irq number
|
|
||||||
+ */
|
|
||||||
+ base = ACPI_IO_BASE;
|
|
||||||
+ gpe_len = ACPI_GPE0_LEN;
|
|
||||||
+ acpi_aci_irq = ACPI_SCI_IRQ;
|
|
||||||
+
|
|
||||||
+ pm->irq = pic[acpi_aci_irq - 64];
|
|
||||||
+ memory_region_init(&pm->iomem, NULL, "ls7a_pm", ACPI_IO_SIZE);
|
|
||||||
+ memory_region_add_subregion(get_system_memory(), base, &pm->iomem);
|
|
||||||
+
|
|
||||||
+ cpu_hotplug_hw_init(get_system_memory(), NULL, &pm->cpuhp_state,
|
|
||||||
+ CPU_HOTPLUG_BASE);
|
|
||||||
+
|
|
||||||
+ ls7a_pm_tmr_init(&pm->acpi_regs, ls7a_pm_update_sci_fn, &pm->iomem,
|
|
||||||
+ LS7A_PM_TMR_BLK);
|
|
||||||
+ ls7a_pm1_evt_init(&pm->acpi_regs, ls7a_pm_update_sci_fn, &pm->iomem,
|
|
||||||
+ LS7A_PM_EVT_BLK);
|
|
||||||
+ ls7a_pm1_cnt_init(&pm->acpi_regs, &pm->iomem, false, false, 2,
|
|
||||||
+ LS7A_PM_CNT_BLK);
|
|
||||||
+
|
|
||||||
+ acpi_gpe_init(&pm->acpi_regs, gpe_len);
|
|
||||||
+ memory_region_init_io(&pm->iomem_gpe, NULL, &ls7a_gpe_ops, pm, "acpi-gpe0",
|
|
||||||
+ gpe_len);
|
|
||||||
+ memory_region_add_subregion(&pm->iomem, LS7A_GPE0_STS_REG, &pm->iomem_gpe);
|
|
||||||
+
|
|
||||||
+ memory_region_init_io(&pm->iomem_reset, NULL, &ls7a_reset_ops, pm,
|
|
||||||
+ "acpi-reset", 4);
|
|
||||||
+ memory_region_add_subregion(&pm->iomem, LS7A_GPE0_RESET_REG,
|
|
||||||
+ &pm->iomem_reset);
|
|
||||||
+
|
|
||||||
+ qemu_register_reset(ls7a_pm_reset, pm);
|
|
||||||
+
|
|
||||||
+ pm->powerdown_notifier.notify = pm_powerdown_req;
|
|
||||||
+ qemu_register_powerdown_notifier(&pm->powerdown_notifier);
|
|
||||||
+
|
|
||||||
+ if (pm->acpi_memory_hotplug.is_enabled) {
|
|
||||||
+ acpi_memory_hotplug_init(get_system_memory(), NULL,
|
|
||||||
+ &pm->acpi_memory_hotplug,
|
|
||||||
+ MEMORY_HOTPLUG_BASE);
|
|
||||||
+ }
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+static void ls7a_pm_get_gpe0_blk(Object *obj, Visitor *v, const char *name,
|
|
||||||
+ void *opaque, Error **errp)
|
|
||||||
+{
|
|
||||||
+ uint64_t value = ACPI_IO_BASE + LS7A_GPE0_STS_REG;
|
|
||||||
+
|
|
||||||
+ visit_type_uint64(v, name, &value, errp);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+static bool ls7a_pm_get_memory_hotplug_support(Object *obj, Error **errp)
|
|
||||||
+{
|
|
||||||
+ LS7APCIState *ls7a = get_ls7a_type(obj);
|
|
||||||
+
|
|
||||||
+ return ls7a->pm.acpi_memory_hotplug.is_enabled;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+static void ls7a_pm_set_memory_hotplug_support(Object *obj, bool value,
|
|
||||||
+ Error **errp)
|
|
||||||
+{
|
|
||||||
+ LS7APCIState *ls7a = get_ls7a_type(obj);
|
|
||||||
+
|
|
||||||
+ ls7a->pm.acpi_memory_hotplug.is_enabled = value;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+static void ls7a_pm_get_disable_s3(Object *obj, Visitor *v, const char *name,
|
|
||||||
+ void *opaque, Error **errp)
|
|
||||||
+{
|
|
||||||
+ LS7APCIPMRegs *pm = opaque;
|
|
||||||
+ uint8_t value = pm->disable_s3;
|
|
||||||
+
|
|
||||||
+ visit_type_uint8(v, name, &value, errp);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+static void ls7a_pm_set_disable_s3(Object *obj, Visitor *v, const char *name,
|
|
||||||
+ void *opaque, Error **errp)
|
|
||||||
+{
|
|
||||||
+ LS7APCIPMRegs *pm = opaque;
|
|
||||||
+ Error *local_err = NULL;
|
|
||||||
+ uint8_t value;
|
|
||||||
+
|
|
||||||
+ visit_type_uint8(v, name, &value, &local_err);
|
|
||||||
+ if (local_err) {
|
|
||||||
+ goto out;
|
|
||||||
+ }
|
|
||||||
+ pm->disable_s3 = value;
|
|
||||||
+out:
|
|
||||||
+ error_propagate(errp, local_err);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+static void ls7a_pm_get_disable_s4(Object *obj, Visitor *v, const char *name,
|
|
||||||
+ void *opaque, Error **errp)
|
|
||||||
+{
|
|
||||||
+ LS7APCIPMRegs *pm = opaque;
|
|
||||||
+ uint8_t value = pm->disable_s4;
|
|
||||||
+
|
|
||||||
+ visit_type_uint8(v, name, &value, errp);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+static void ls7a_pm_set_disable_s4(Object *obj, Visitor *v, const char *name,
|
|
||||||
+ void *opaque, Error **errp)
|
|
||||||
+{
|
|
||||||
+ LS7APCIPMRegs *pm = opaque;
|
|
||||||
+ Error *local_err = NULL;
|
|
||||||
+ uint8_t value;
|
|
||||||
+
|
|
||||||
+ visit_type_uint8(v, name, &value, &local_err);
|
|
||||||
+ if (local_err) {
|
|
||||||
+ goto out;
|
|
||||||
+ }
|
|
||||||
+ pm->disable_s4 = value;
|
|
||||||
+out:
|
|
||||||
+ error_propagate(errp, local_err);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+static void ls7a_pm_get_s4_val(Object *obj, Visitor *v, const char *name,
|
|
||||||
+ void *opaque, Error **errp)
|
|
||||||
+{
|
|
||||||
+ LS7APCIPMRegs *pm = opaque;
|
|
||||||
+ uint8_t value = pm->s4_val;
|
|
||||||
+
|
|
||||||
+ visit_type_uint8(v, name, &value, errp);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+static void ls7a_pm_set_s4_val(Object *obj, Visitor *v, const char *name,
|
|
||||||
+ void *opaque, Error **errp)
|
|
||||||
+{
|
|
||||||
+ LS7APCIPMRegs *pm = opaque;
|
|
||||||
+ Error *local_err = NULL;
|
|
||||||
+ uint8_t value;
|
|
||||||
+
|
|
||||||
+ visit_type_uint8(v, name, &value, &local_err);
|
|
||||||
+ if (local_err) {
|
|
||||||
+ goto out;
|
|
||||||
+ }
|
|
||||||
+ pm->s4_val = value;
|
|
||||||
+out:
|
|
||||||
+ error_propagate(errp, local_err);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+void ls7a_pm_add_properties(Object *obj, LS7APCIPMRegs *pm, Error **errp)
|
|
||||||
+{
|
|
||||||
+ static const uint32_t gpe0_len = ACPI_GPE0_LEN;
|
|
||||||
+ pm->acpi_memory_hotplug.is_enabled = true;
|
|
||||||
+ pm->disable_s3 = 0;
|
|
||||||
+ pm->disable_s4 = 0;
|
|
||||||
+ pm->s4_val = 2;
|
|
||||||
+
|
|
||||||
+ object_property_add_uint32_ptr(obj, ACPI_PM_PROP_PM_IO_BASE,
|
|
||||||
+ &pm->pm_io_base, OBJ_PROP_FLAG_READ);
|
|
||||||
+ object_property_add(obj, ACPI_PM_PROP_GPE0_BLK, "uint32",
|
|
||||||
+ ls7a_pm_get_gpe0_blk, NULL, NULL, pm);
|
|
||||||
+ object_property_add_uint32_ptr(obj, ACPI_PM_PROP_GPE0_BLK_LEN, &gpe0_len,
|
|
||||||
+ OBJ_PROP_FLAG_READ);
|
|
||||||
+ object_property_add_bool(obj, "memory-hotplug-support",
|
|
||||||
+ ls7a_pm_get_memory_hotplug_support,
|
|
||||||
+ ls7a_pm_set_memory_hotplug_support);
|
|
||||||
+ object_property_add(obj, ACPI_PM_PROP_S3_DISABLED, "uint8",
|
|
||||||
+ ls7a_pm_get_disable_s3, ls7a_pm_set_disable_s3, NULL,
|
|
||||||
+ pm);
|
|
||||||
+ object_property_add(obj, ACPI_PM_PROP_S4_DISABLED, "uint8",
|
|
||||||
+ ls7a_pm_get_disable_s4, ls7a_pm_set_disable_s4, NULL,
|
|
||||||
+ pm);
|
|
||||||
+ object_property_add(obj, ACPI_PM_PROP_S4_VAL, "uint8", ls7a_pm_get_s4_val,
|
|
||||||
+ ls7a_pm_set_s4_val, NULL, pm);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+void ls7a_pm_device_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev,
|
|
||||||
+ Error **errp)
|
|
||||||
+{
|
|
||||||
+ LS7APCIState *ls7a = get_ls7a_type(OBJECT(hotplug_dev));
|
|
||||||
+
|
|
||||||
+ if (ls7a->pm.acpi_memory_hotplug.is_enabled &&
|
|
||||||
+ object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) {
|
|
||||||
+ if (object_dynamic_cast(OBJECT(dev), TYPE_NVDIMM)) {
|
|
||||||
+ nvdimm_acpi_plug_cb(hotplug_dev, dev);
|
|
||||||
+ } else {
|
|
||||||
+ acpi_memory_plug_cb(hotplug_dev, &ls7a->pm.acpi_memory_hotplug,
|
|
||||||
+ dev, errp);
|
|
||||||
+ }
|
|
||||||
+ } else if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) {
|
|
||||||
+ acpi_cpu_plug_cb(hotplug_dev, &ls7a->pm.cpuhp_state, dev, errp);
|
|
||||||
+ } else {
|
|
||||||
+ error_setg(errp,
|
|
||||||
+ "acpi: device plug request for not supported device"
|
|
||||||
+ " type: %s",
|
|
||||||
+ object_get_typename(OBJECT(dev)));
|
|
||||||
+ }
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+void ls7a_pm_device_unplug_request_cb(HotplugHandler *hotplug_dev,
|
|
||||||
+ DeviceState *dev, Error **errp)
|
|
||||||
+{
|
|
||||||
+ LS7APCIState *ls7a = get_ls7a_type(OBJECT(hotplug_dev));
|
|
||||||
+
|
|
||||||
+ if (ls7a->pm.acpi_memory_hotplug.is_enabled &&
|
|
||||||
+ object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) {
|
|
||||||
+ acpi_memory_unplug_request_cb(
|
|
||||||
+ hotplug_dev, &ls7a->pm.acpi_memory_hotplug, dev, errp);
|
|
||||||
+ } else if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) {
|
|
||||||
+ acpi_cpu_unplug_request_cb(hotplug_dev, &ls7a->pm.cpuhp_state, dev,
|
|
||||||
+ errp);
|
|
||||||
+ } else {
|
|
||||||
+ error_setg(errp,
|
|
||||||
+ "acpi: device unplug request for not supported device"
|
|
||||||
+ " type: %s",
|
|
||||||
+ object_get_typename(OBJECT(dev)));
|
|
||||||
+ }
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+void ls7a_pm_device_unplug_cb(HotplugHandler *hotplug_dev, DeviceState *dev,
|
|
||||||
+ Error **errp)
|
|
||||||
+{
|
|
||||||
+ LS7APCIState *ls7a = get_ls7a_type(OBJECT(hotplug_dev));
|
|
||||||
+
|
|
||||||
+ if (ls7a->pm.acpi_memory_hotplug.is_enabled &&
|
|
||||||
+ object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) {
|
|
||||||
+ acpi_memory_unplug_cb(&ls7a->pm.acpi_memory_hotplug, dev, errp);
|
|
||||||
+ } else if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) {
|
|
||||||
+ acpi_cpu_unplug_cb(&ls7a->pm.cpuhp_state, dev, errp);
|
|
||||||
+ } else {
|
|
||||||
+ error_setg(errp,
|
|
||||||
+ "acpi: device unplug for not supported device"
|
|
||||||
+ " type: %s",
|
|
||||||
+ object_get_typename(OBJECT(dev)));
|
|
||||||
+ }
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+void ls7a_pm_ospm_status(AcpiDeviceIf *adev, ACPIOSTInfoList ***list)
|
|
||||||
+{
|
|
||||||
+ LS7APCIState *ls7a = get_ls7a_type(OBJECT(adev));
|
|
||||||
+
|
|
||||||
+ acpi_memory_ospm_status(&ls7a->pm.acpi_memory_hotplug, list);
|
|
||||||
+ acpi_cpu_ospm_status(&ls7a->pm.cpuhp_state, list);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+void ls7a_send_gpe(AcpiDeviceIf *adev, AcpiEventStatusBits ev)
|
|
||||||
+{
|
|
||||||
+ LS7APCIState *ls7a = get_ls7a_type(OBJECT(adev));
|
|
||||||
+
|
|
||||||
+ acpi_send_gpe_event(&ls7a->pm.acpi_regs, ls7a->pm.irq, ev);
|
|
||||||
+}
|
|
||||||
diff --git a/hw/acpi/meson.build b/hw/acpi/meson.build
|
|
||||||
index 448ea6afb4..4718d143fc 100644
|
|
||||||
--- a/hw/acpi/meson.build
|
|
||||||
+++ b/hw/acpi/meson.build
|
|
||||||
@@ -6,6 +6,7 @@ acpi_ss.add(files(
|
|
||||||
'core.c',
|
|
||||||
'utils.c',
|
|
||||||
))
|
|
||||||
+acpi_ss.add(when: 'CONFIG_ACPI_LOONGARCH', if_true: files('larch_7a.c'))
|
|
||||||
acpi_ss.add(when: 'CONFIG_ACPI_CPU_HOTPLUG', if_true: files('cpu.c', 'cpu_hotplug.c'))
|
|
||||||
acpi_ss.add(when: 'CONFIG_ACPI_CPU_HOTPLUG', if_false: files('acpi-cpu-hotplug-stub.c'))
|
|
||||||
acpi_ss.add(when: 'CONFIG_ACPI_MEMORY_HOTPLUG', if_true: files('memory_hotplug.c'))
|
|
||||||
diff --git a/include/hw/acpi/ls7a.h b/include/hw/acpi/ls7a.h
|
|
||||||
new file mode 100644
|
|
||||||
index 0000000000..295baa4b5a
|
|
||||||
--- /dev/null
|
|
||||||
+++ b/include/hw/acpi/ls7a.h
|
|
||||||
@@ -0,0 +1,79 @@
|
|
||||||
+/*
|
|
||||||
+ * QEMU GMCH/LS7A PCI PM Emulation
|
|
||||||
+ *
|
|
||||||
+ * Copyright (c) 2023 Loongarch Technology
|
|
||||||
+ *
|
|
||||||
+ * This program is free software; you can redistribute it and/or modify it
|
|
||||||
+ * under the terms and conditions of the GNU General Public License,
|
|
||||||
+ * version 2 or later, as published by the Free Software Foundation.
|
|
||||||
+ *
|
|
||||||
+ * This program is distributed in the hope it will be useful, but WITHOUT
|
|
||||||
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
||||||
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
||||||
+ * more details.
|
|
||||||
+ *
|
|
||||||
+ * You should have received a copy of the GNU General Public License along with
|
|
||||||
+ * this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
+ *
|
|
||||||
+ */
|
|
||||||
+
|
|
||||||
+#ifndef HW_ACPI_LS7A_H
|
|
||||||
+#define HW_ACPI_LS7A_H
|
|
||||||
+
|
|
||||||
+#include "hw/acpi/acpi.h"
|
|
||||||
+#include "hw/acpi/cpu_hotplug.h"
|
|
||||||
+#include "hw/acpi/cpu.h"
|
|
||||||
+#include "hw/acpi/memory_hotplug.h"
|
|
||||||
+#include "hw/acpi/acpi_dev_interface.h"
|
|
||||||
+#include "hw/acpi/tco.h"
|
|
||||||
+
|
|
||||||
+#define CPU_HOTPLUG_BASE 0x1e000000
|
|
||||||
+#define MEMORY_HOTPLUG_BASE 0x1e00000c
|
|
||||||
+
|
|
||||||
+typedef struct LS7APCIPMRegs {
|
|
||||||
+ /*
|
|
||||||
+ * In ls7a spec says that pm1_cnt register is 32bit width and
|
|
||||||
+ * that the upper 16bits are reserved and unused.
|
|
||||||
+ * PM1a_CNT_BLK = 2 in FADT so it is defined as uint16_t.
|
|
||||||
+ */
|
|
||||||
+ ACPIREGS acpi_regs;
|
|
||||||
+
|
|
||||||
+ MemoryRegion iomem;
|
|
||||||
+ MemoryRegion iomem_gpe;
|
|
||||||
+ MemoryRegion iomem_smi;
|
|
||||||
+ MemoryRegion iomem_reset;
|
|
||||||
+
|
|
||||||
+ qemu_irq irq; /* SCI */
|
|
||||||
+
|
|
||||||
+ uint32_t pm_io_base;
|
|
||||||
+ Notifier powerdown_notifier;
|
|
||||||
+
|
|
||||||
+ bool cpu_hotplug_legacy;
|
|
||||||
+ AcpiCpuHotplug gpe_cpu;
|
|
||||||
+ CPUHotplugState cpuhp_state;
|
|
||||||
+
|
|
||||||
+ MemHotplugState acpi_memory_hotplug;
|
|
||||||
+
|
|
||||||
+ uint8_t disable_s3;
|
|
||||||
+ uint8_t disable_s4;
|
|
||||||
+ uint8_t s4_val;
|
|
||||||
+} LS7APCIPMRegs;
|
|
||||||
+
|
|
||||||
+void ls7a_pm_init(LS7APCIPMRegs *ls7a, qemu_irq *sci_irq);
|
|
||||||
+
|
|
||||||
+void ls7a_pm_iospace_update(LS7APCIPMRegs *pm, uint32_t pm_io_base);
|
|
||||||
+extern const VMStateDescription vmstate_ls7a_pm;
|
|
||||||
+
|
|
||||||
+void ls7a_pm_add_properties(Object *obj, LS7APCIPMRegs *pm, Error **errp);
|
|
||||||
+
|
|
||||||
+void ls7a_pm_device_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev,
|
|
||||||
+ Error **errp);
|
|
||||||
+void ls7a_pm_device_unplug_request_cb(HotplugHandler *hotplug_dev,
|
|
||||||
+ DeviceState *dev, Error **errp);
|
|
||||||
+void ls7a_pm_device_unplug_cb(HotplugHandler *hotplug_dev, DeviceState *dev,
|
|
||||||
+ Error **errp);
|
|
||||||
+
|
|
||||||
+void ls7a_pm_ospm_status(AcpiDeviceIf *adev, ACPIOSTInfoList ***list);
|
|
||||||
+
|
|
||||||
+void ls7a_send_gpe(AcpiDeviceIf *adev, AcpiEventStatusBits ev);
|
|
||||||
+#endif /* HW_ACPI_LS7A_H */
|
|
||||||
--
|
|
||||||
2.27.0
|
|
||||||
|
|
||||||
@ -1,402 +0,0 @@
|
|||||||
From 1b831c95e652d185c20efe74457927f5d7e35153 Mon Sep 17 00:00:00 2001
|
|
||||||
From: lixianglai <lixianglai@loongson.cn>
|
|
||||||
Date: Tue, 7 Feb 2023 06:35:16 -0500
|
|
||||||
Subject: [PATCH] Add RTC support.
|
|
||||||
|
|
||||||
Add Loongarch real-time clock device simulation.
|
|
||||||
|
|
||||||
Signed-off-by: lixianglai <lixianglai@loongson.cn>
|
|
||||||
---
|
|
||||||
hw/meson.build | 1 +
|
|
||||||
hw/timer/Kconfig | 2 +
|
|
||||||
hw/timer/ls7a_rtc.c | 343 +++++++++++++++++++++++++++++++++++++++++++
|
|
||||||
hw/timer/meson.build | 1 +
|
|
||||||
4 files changed, 347 insertions(+)
|
|
||||||
create mode 100644 hw/timer/ls7a_rtc.c
|
|
||||||
|
|
||||||
diff --git a/hw/meson.build b/hw/meson.build
|
|
||||||
index f39c1f7e70..a9a078ec33 100644
|
|
||||||
--- a/hw/meson.build
|
|
||||||
+++ b/hw/meson.build
|
|
||||||
@@ -17,6 +17,7 @@ subdir('intc')
|
|
||||||
subdir('ipack')
|
|
||||||
subdir('ipmi')
|
|
||||||
subdir('isa')
|
|
||||||
+subdir('loongarch')
|
|
||||||
subdir('mem')
|
|
||||||
subdir('misc')
|
|
||||||
subdir('net')
|
|
||||||
diff --git a/hw/timer/Kconfig b/hw/timer/Kconfig
|
|
||||||
index 010be7ed1f..b395c72d7d 100644
|
|
||||||
--- a/hw/timer/Kconfig
|
|
||||||
+++ b/hw/timer/Kconfig
|
|
||||||
@@ -60,3 +60,5 @@ config STELLARIS_GPTM
|
|
||||||
|
|
||||||
config AVR_TIMER16
|
|
||||||
bool
|
|
||||||
+config LS7A_RTC
|
|
||||||
+ bool
|
|
||||||
diff --git a/hw/timer/ls7a_rtc.c b/hw/timer/ls7a_rtc.c
|
|
||||||
new file mode 100644
|
|
||||||
index 0000000000..56c2695654
|
|
||||||
--- /dev/null
|
|
||||||
+++ b/hw/timer/ls7a_rtc.c
|
|
||||||
@@ -0,0 +1,343 @@
|
|
||||||
+/*
|
|
||||||
+ * Loongarch rtc emulation
|
|
||||||
+ *
|
|
||||||
+ * Copyright (c) 2023 Loongarch Technology
|
|
||||||
+ *
|
|
||||||
+ * This program is free software; you can redistribute it and/or modify it
|
|
||||||
+ * under the terms and conditions of the GNU General Public License,
|
|
||||||
+ * version 2 or later, as published by the Free Software Foundation.
|
|
||||||
+ *
|
|
||||||
+ * This program is distributed in the hope it will be useful, but WITHOUT
|
|
||||||
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
||||||
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
||||||
+ * more details.
|
|
||||||
+ *
|
|
||||||
+ * You should have received a copy of the GNU General Public License along with
|
|
||||||
+ * this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
+ *
|
|
||||||
+ */
|
|
||||||
+
|
|
||||||
+#include "qemu/osdep.h"
|
|
||||||
+#include "hw/sysbus.h"
|
|
||||||
+#include "hw/irq.h"
|
|
||||||
+#include "include/hw/register.h"
|
|
||||||
+#include "qemu/timer.h"
|
|
||||||
+#include "sysemu/sysemu.h"
|
|
||||||
+#include "qemu/cutils.h"
|
|
||||||
+#include "qemu/log.h"
|
|
||||||
+#include "qemu-common.h"
|
|
||||||
+#include "migration/vmstate.h"
|
|
||||||
+
|
|
||||||
+#ifdef DEBUG_LS7A_RTC
|
|
||||||
+#define DPRINTF \
|
|
||||||
+ (fmt, ...) do \
|
|
||||||
+ { \
|
|
||||||
+ printf("ls7a_rtc: " fmt, ##__VA_ARGS__); \
|
|
||||||
+ } \
|
|
||||||
+ while (0)
|
|
||||||
+#else
|
|
||||||
+#define DPRINTF \
|
|
||||||
+ (fmt, ...) do \
|
|
||||||
+ { \
|
|
||||||
+ } \
|
|
||||||
+ while (0)
|
|
||||||
+#endif
|
|
||||||
+
|
|
||||||
+#define SYS_TOYTRIM 0x20
|
|
||||||
+#define SYS_TOYWRITE0 0x24
|
|
||||||
+#define SYS_TOYWRITE1 0x28
|
|
||||||
+#define SYS_TOYREAD0 0x2C
|
|
||||||
+#define SYS_TOYREAD1 0x30
|
|
||||||
+#define SYS_TOYMATCH0 0x34
|
|
||||||
+#define SYS_TOYMATCH1 0x38
|
|
||||||
+#define SYS_TOYMATCH2 0x3C
|
|
||||||
+#define SYS_RTCCTRL 0x40
|
|
||||||
+#define SYS_RTCTRIM 0x60
|
|
||||||
+#define SYS_RTCWRTIE0 0x64
|
|
||||||
+#define SYS_RTCREAD0 0x68
|
|
||||||
+#define SYS_RTCMATCH0 0x6C
|
|
||||||
+#define SYS_RTCMATCH1 0x70
|
|
||||||
+#define SYS_RTCMATCH2 0x74
|
|
||||||
+
|
|
||||||
+/**
|
|
||||||
+ ** shift bits and filed mask
|
|
||||||
+ **/
|
|
||||||
+#define TOY_MON_MASK 0x3f
|
|
||||||
+#define TOY_DAY_MASK 0x1f
|
|
||||||
+#define TOY_HOUR_MASK 0x1f
|
|
||||||
+#define TOY_MIN_MASK 0x3f
|
|
||||||
+#define TOY_SEC_MASK 0x3f
|
|
||||||
+#define TOY_MSEC_MASK 0xf
|
|
||||||
+
|
|
||||||
+#define TOY_MON_SHIFT 26
|
|
||||||
+#define TOY_DAY_SHIFT 21
|
|
||||||
+#define TOY_HOUR_SHIFT 16
|
|
||||||
+#define TOY_MIN_SHIFT 10
|
|
||||||
+#define TOY_SEC_SHIFT 4
|
|
||||||
+#define TOY_MSEC_SHIFT 0
|
|
||||||
+
|
|
||||||
+#define TOY_MATCH_YEAR_MASK 0x3f
|
|
||||||
+#define TOY_MATCH_MON_MASK 0xf
|
|
||||||
+#define TOY_MATCH_DAY_MASK 0x1f
|
|
||||||
+#define TOY_MATCH_HOUR_MASK 0x1f
|
|
||||||
+#define TOY_MATCH_MIN_MASK 0x3f
|
|
||||||
+#define TOY_MATCH_SEC_MASK 0x3f
|
|
||||||
+
|
|
||||||
+#define TOY_MATCH_YEAR_SHIFT 26
|
|
||||||
+#define TOY_MATCH_MON_SHIFT 22
|
|
||||||
+#define TOY_MATCH_DAY_SHIFT 17
|
|
||||||
+#define TOY_MATCH_HOUR_SHIFT 12
|
|
||||||
+#define TOY_MATCH_MIN_SHIFT 6
|
|
||||||
+#define TOY_MATCH_SEC_SHIFT 0
|
|
||||||
+
|
|
||||||
+#define TOY_ENABLE_BIT (1U << 11)
|
|
||||||
+
|
|
||||||
+#define TYPE_LS7A_RTC "ls7a_rtc"
|
|
||||||
+#define LS7A_RTC(obj) OBJECT_CHECK(LS7A_RTCState, (obj), TYPE_LS7A_RTC)
|
|
||||||
+
|
|
||||||
+typedef struct LS7A_RTCState {
|
|
||||||
+ SysBusDevice parent_obj;
|
|
||||||
+
|
|
||||||
+ MemoryRegion iomem;
|
|
||||||
+ QEMUTimer *timer;
|
|
||||||
+ /*
|
|
||||||
+ * Needed to preserve the tick_count across migration, even if the
|
|
||||||
+ * absolute value of the rtc_clock is different on the source and
|
|
||||||
+ * destination.
|
|
||||||
+ */
|
|
||||||
+ int64_t offset;
|
|
||||||
+ int64_t data;
|
|
||||||
+ int64_t save_alarm_offset;
|
|
||||||
+ int tidx;
|
|
||||||
+ uint32_t toymatch[3];
|
|
||||||
+ uint32_t toytrim;
|
|
||||||
+ uint32_t cntrctl;
|
|
||||||
+ uint32_t rtctrim;
|
|
||||||
+ uint32_t rtccount;
|
|
||||||
+ uint32_t rtcmatch[3];
|
|
||||||
+ qemu_irq toy_irq;
|
|
||||||
+} LS7A_RTCState;
|
|
||||||
+
|
|
||||||
+enum {
|
|
||||||
+ TOYEN = 1UL << 11,
|
|
||||||
+ RTCEN = 1UL << 13,
|
|
||||||
+};
|
|
||||||
+
|
|
||||||
+static uint64_t ls7a_rtc_read(void *opaque, hwaddr addr, unsigned size)
|
|
||||||
+{
|
|
||||||
+ LS7A_RTCState *s = (LS7A_RTCState *)opaque;
|
|
||||||
+ struct tm tm;
|
|
||||||
+ unsigned int val = 0;
|
|
||||||
+
|
|
||||||
+ switch (addr) {
|
|
||||||
+ case SYS_TOYREAD0:
|
|
||||||
+ qemu_get_timedate(&tm, s->offset);
|
|
||||||
+ val = (((tm.tm_mon + 1) & TOY_MON_MASK) << TOY_MON_SHIFT) |
|
|
||||||
+ (((tm.tm_mday) & TOY_DAY_MASK) << TOY_DAY_SHIFT) |
|
|
||||||
+ (((tm.tm_hour) & TOY_HOUR_MASK) << TOY_HOUR_SHIFT) |
|
|
||||||
+ (((tm.tm_min) & TOY_MIN_MASK) << TOY_MIN_SHIFT) |
|
|
||||||
+ (((tm.tm_sec) & TOY_SEC_MASK) << TOY_SEC_SHIFT) | 0x0;
|
|
||||||
+ break;
|
|
||||||
+ case SYS_TOYREAD1:
|
|
||||||
+ qemu_get_timedate(&tm, s->offset);
|
|
||||||
+ val = tm.tm_year;
|
|
||||||
+ break;
|
|
||||||
+ case SYS_TOYMATCH0:
|
|
||||||
+ val = s->toymatch[0];
|
|
||||||
+ break;
|
|
||||||
+ case SYS_TOYMATCH1:
|
|
||||||
+ val = s->toymatch[1];
|
|
||||||
+ break;
|
|
||||||
+ case SYS_TOYMATCH2:
|
|
||||||
+ val = s->toymatch[2];
|
|
||||||
+ break;
|
|
||||||
+ case SYS_RTCCTRL:
|
|
||||||
+ val = s->cntrctl;
|
|
||||||
+ break;
|
|
||||||
+ case SYS_RTCREAD0:
|
|
||||||
+ val = s->rtccount;
|
|
||||||
+ break;
|
|
||||||
+ case SYS_RTCMATCH0:
|
|
||||||
+ val = s->rtcmatch[0];
|
|
||||||
+ break;
|
|
||||||
+ case SYS_RTCMATCH1:
|
|
||||||
+ val = s->rtcmatch[1];
|
|
||||||
+ break;
|
|
||||||
+ case SYS_RTCMATCH2:
|
|
||||||
+ val = s->rtcmatch[2];
|
|
||||||
+ break;
|
|
||||||
+ default:
|
|
||||||
+ break;
|
|
||||||
+ }
|
|
||||||
+ return val;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+static void ls7a_rtc_write(void *opaque, hwaddr addr, uint64_t val,
|
|
||||||
+ unsigned size)
|
|
||||||
+{
|
|
||||||
+ LS7A_RTCState *s = (LS7A_RTCState *)opaque;
|
|
||||||
+ struct tm tm;
|
|
||||||
+ int64_t alarm_offset, year_diff, expire_time;
|
|
||||||
+
|
|
||||||
+ switch (addr) {
|
|
||||||
+ case SYS_TOYWRITE0:
|
|
||||||
+ qemu_get_timedate(&tm, s->offset);
|
|
||||||
+ tm.tm_sec = (val >> TOY_SEC_SHIFT) & TOY_SEC_MASK;
|
|
||||||
+ tm.tm_min = (val >> TOY_MIN_SHIFT) & TOY_MIN_MASK;
|
|
||||||
+ tm.tm_hour = (val >> TOY_HOUR_SHIFT) & TOY_HOUR_MASK;
|
|
||||||
+ tm.tm_mday = ((val >> TOY_DAY_SHIFT) & TOY_DAY_MASK);
|
|
||||||
+ tm.tm_mon = ((val >> TOY_MON_SHIFT) & TOY_MON_MASK) - 1;
|
|
||||||
+ s->offset = qemu_timedate_diff(&tm);
|
|
||||||
+ break;
|
|
||||||
+ case SYS_TOYWRITE1:
|
|
||||||
+ qemu_get_timedate(&tm, s->offset);
|
|
||||||
+ tm.tm_year = val;
|
|
||||||
+ s->offset = qemu_timedate_diff(&tm);
|
|
||||||
+ break;
|
|
||||||
+ case SYS_TOYMATCH0:
|
|
||||||
+ s->toymatch[0] = val;
|
|
||||||
+ qemu_get_timedate(&tm, s->offset);
|
|
||||||
+ tm.tm_sec = (val >> TOY_MATCH_SEC_SHIFT) & TOY_MATCH_SEC_MASK;
|
|
||||||
+ tm.tm_min = (val >> TOY_MATCH_MIN_SHIFT) & TOY_MATCH_MIN_MASK;
|
|
||||||
+ tm.tm_hour = ((val >> TOY_MATCH_HOUR_SHIFT) & TOY_MATCH_HOUR_MASK);
|
|
||||||
+ tm.tm_mday = ((val >> TOY_MATCH_DAY_SHIFT) & TOY_MATCH_DAY_MASK);
|
|
||||||
+ tm.tm_mon = ((val >> TOY_MATCH_MON_SHIFT) & TOY_MATCH_MON_MASK) - 1;
|
|
||||||
+ year_diff = ((val >> TOY_MATCH_YEAR_SHIFT) & TOY_MATCH_YEAR_MASK);
|
|
||||||
+ year_diff = year_diff - (tm.tm_year & TOY_MATCH_YEAR_MASK);
|
|
||||||
+ tm.tm_year = tm.tm_year + year_diff;
|
|
||||||
+ alarm_offset = qemu_timedate_diff(&tm) - s->offset;
|
|
||||||
+ if ((alarm_offset < 0) && (alarm_offset > -5)) {
|
|
||||||
+ alarm_offset = 0;
|
|
||||||
+ }
|
|
||||||
+ expire_time = qemu_clock_get_ms(rtc_clock);
|
|
||||||
+ expire_time += ((alarm_offset * 1000) + 100);
|
|
||||||
+ timer_mod(s->timer, expire_time);
|
|
||||||
+ break;
|
|
||||||
+ case SYS_TOYMATCH1:
|
|
||||||
+ s->toymatch[1] = val;
|
|
||||||
+ break;
|
|
||||||
+ case SYS_TOYMATCH2:
|
|
||||||
+ s->toymatch[2] = val;
|
|
||||||
+ break;
|
|
||||||
+ case SYS_RTCCTRL:
|
|
||||||
+ s->cntrctl = val;
|
|
||||||
+ break;
|
|
||||||
+ case SYS_RTCWRTIE0:
|
|
||||||
+ s->rtccount = val;
|
|
||||||
+ break;
|
|
||||||
+ case SYS_RTCMATCH0:
|
|
||||||
+ s->rtcmatch[0] = val;
|
|
||||||
+ break;
|
|
||||||
+ case SYS_RTCMATCH1:
|
|
||||||
+ val = s->rtcmatch[1];
|
|
||||||
+ break;
|
|
||||||
+ case SYS_RTCMATCH2:
|
|
||||||
+ val = s->rtcmatch[2];
|
|
||||||
+ break;
|
|
||||||
+ default:
|
|
||||||
+ break;
|
|
||||||
+ }
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+static const MemoryRegionOps ls7a_rtc_ops = {
|
|
||||||
+ .read = ls7a_rtc_read,
|
|
||||||
+ .write = ls7a_rtc_write,
|
|
||||||
+ .endianness = DEVICE_NATIVE_ENDIAN,
|
|
||||||
+ .valid = {
|
|
||||||
+ .min_access_size = 4,
|
|
||||||
+ .max_access_size = 4,
|
|
||||||
+ },
|
|
||||||
+
|
|
||||||
+};
|
|
||||||
+
|
|
||||||
+static void toy_timer(void *opaque)
|
|
||||||
+{
|
|
||||||
+ LS7A_RTCState *s = (LS7A_RTCState *)opaque;
|
|
||||||
+
|
|
||||||
+ if (s->cntrctl & TOY_ENABLE_BIT) {
|
|
||||||
+ qemu_irq_pulse(s->toy_irq);
|
|
||||||
+ }
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+static void ls7a_rtc_realize(DeviceState *dev, Error **errp)
|
|
||||||
+{
|
|
||||||
+ SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
|
|
||||||
+ LS7A_RTCState *d = LS7A_RTC(sbd);
|
|
||||||
+ memory_region_init_io(&d->iomem, NULL, &ls7a_rtc_ops, (void *)d,
|
|
||||||
+ "ls7a_rtc", 0x100);
|
|
||||||
+
|
|
||||||
+ sysbus_init_irq(sbd, &d->toy_irq);
|
|
||||||
+
|
|
||||||
+ sysbus_init_mmio(sbd, &d->iomem);
|
|
||||||
+ d->timer = timer_new_ms(rtc_clock, toy_timer, d);
|
|
||||||
+ timer_mod(d->timer, qemu_clock_get_ms(rtc_clock) + 100);
|
|
||||||
+ d->offset = 0;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+static int ls7a_rtc_pre_save(void *opaque)
|
|
||||||
+{
|
|
||||||
+ LS7A_RTCState *s = (LS7A_RTCState *)opaque;
|
|
||||||
+ struct tm tm;
|
|
||||||
+ int64_t year_diff, value;
|
|
||||||
+
|
|
||||||
+ value = s->toymatch[0];
|
|
||||||
+ qemu_get_timedate(&tm, s->offset);
|
|
||||||
+ tm.tm_sec = (value >> TOY_MATCH_SEC_SHIFT) & TOY_MATCH_SEC_MASK;
|
|
||||||
+ tm.tm_min = (value >> TOY_MATCH_MIN_SHIFT) & TOY_MATCH_MIN_MASK;
|
|
||||||
+ tm.tm_hour = ((value >> TOY_MATCH_HOUR_SHIFT) & TOY_MATCH_HOUR_MASK);
|
|
||||||
+ tm.tm_mday = ((value >> TOY_MATCH_DAY_SHIFT) & TOY_MATCH_DAY_MASK);
|
|
||||||
+ tm.tm_mon = ((value >> TOY_MATCH_MON_SHIFT) & TOY_MATCH_MON_MASK) - 1;
|
|
||||||
+ year_diff = ((value >> TOY_MATCH_YEAR_SHIFT) & TOY_MATCH_YEAR_MASK);
|
|
||||||
+ year_diff = year_diff - (tm.tm_year & TOY_MATCH_YEAR_MASK);
|
|
||||||
+ tm.tm_year = tm.tm_year + year_diff;
|
|
||||||
+ s->save_alarm_offset = qemu_timedate_diff(&tm) - s->offset;
|
|
||||||
+
|
|
||||||
+ return 0;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+static int ls7a_rtc_post_load(void *opaque, int version_id)
|
|
||||||
+{
|
|
||||||
+ LS7A_RTCState *s = (LS7A_RTCState *)opaque;
|
|
||||||
+ int64_t expire_time;
|
|
||||||
+
|
|
||||||
+ expire_time = qemu_clock_get_ms(rtc_clock) + (s->save_alarm_offset * 1000);
|
|
||||||
+ timer_mod(s->timer, expire_time);
|
|
||||||
+
|
|
||||||
+ return 0;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+static const VMStateDescription vmstate_ls7a_rtc = {
|
|
||||||
+ .name = "ls7a_rtc",
|
|
||||||
+ .version_id = 1,
|
|
||||||
+ .minimum_version_id = 1,
|
|
||||||
+ .pre_save = ls7a_rtc_pre_save,
|
|
||||||
+ .post_load = ls7a_rtc_post_load,
|
|
||||||
+ .fields =
|
|
||||||
+ (VMStateField[]){ VMSTATE_INT64(offset, LS7A_RTCState),
|
|
||||||
+ VMSTATE_INT64(save_alarm_offset, LS7A_RTCState),
|
|
||||||
+ VMSTATE_UINT32(toymatch[0], LS7A_RTCState),
|
|
||||||
+ VMSTATE_UINT32(cntrctl, LS7A_RTCState),
|
|
||||||
+ VMSTATE_END_OF_LIST() }
|
|
||||||
+};
|
|
||||||
+
|
|
||||||
+static void ls7a_rtc_class_init(ObjectClass *klass, void *data)
|
|
||||||
+{
|
|
||||||
+ DeviceClass *dc = DEVICE_CLASS(klass);
|
|
||||||
+ dc->vmsd = &vmstate_ls7a_rtc;
|
|
||||||
+ dc->realize = ls7a_rtc_realize;
|
|
||||||
+ dc->desc = "ls7a rtc";
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+static const TypeInfo ls7a_rtc_info = {
|
|
||||||
+ .name = TYPE_LS7A_RTC,
|
|
||||||
+ .parent = TYPE_SYS_BUS_DEVICE,
|
|
||||||
+ .instance_size = sizeof(LS7A_RTCState),
|
|
||||||
+ .class_init = ls7a_rtc_class_init,
|
|
||||||
+};
|
|
||||||
+
|
|
||||||
+static void ls7a_rtc_register_types(void)
|
|
||||||
+{
|
|
||||||
+ type_register_static(&ls7a_rtc_info);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+type_init(ls7a_rtc_register_types)
|
|
||||||
diff --git a/hw/timer/meson.build b/hw/timer/meson.build
|
|
||||||
index 03092e2ceb..e841a2f6ee 100644
|
|
||||||
--- a/hw/timer/meson.build
|
|
||||||
+++ b/hw/timer/meson.build
|
|
||||||
@@ -16,6 +16,7 @@ softmmu_ss.add(when: 'CONFIG_EXYNOS4', if_true: files('exynos4210_mct.c'))
|
|
||||||
softmmu_ss.add(when: 'CONFIG_EXYNOS4', if_true: files('exynos4210_pwm.c'))
|
|
||||||
softmmu_ss.add(when: 'CONFIG_GRLIB', if_true: files('grlib_gptimer.c'))
|
|
||||||
softmmu_ss.add(when: 'CONFIG_HPET', if_true: files('hpet.c'))
|
|
||||||
+softmmu_ss.add(when: 'CONFIG_LS7A_RTC', if_true: files('ls7a_rtc.c'))
|
|
||||||
softmmu_ss.add(when: 'CONFIG_I8254', if_true: files('i8254_common.c', 'i8254.c'))
|
|
||||||
softmmu_ss.add(when: 'CONFIG_IMX', if_true: files('imx_epit.c'))
|
|
||||||
softmmu_ss.add(when: 'CONFIG_IMX', if_true: files('imx_gpt.c'))
|
|
||||||
--
|
|
||||||
2.27.0
|
|
||||||
|
|
||||||
@ -1,28 +0,0 @@
|
|||||||
From 6921fc74a9a58445e453eeb3c2ee74cead690ee4 Mon Sep 17 00:00:00 2001
|
|
||||||
From: lixianglai <lixianglai@loongson.cn>
|
|
||||||
Date: Tue, 7 Feb 2023 07:22:18 -0500
|
|
||||||
Subject: [PATCH] Add bios.
|
|
||||||
|
|
||||||
Add loongarch bios.
|
|
||||||
|
|
||||||
Signed-off-by: lixianglai <lixianglai@loongson.cn>
|
|
||||||
---
|
|
||||||
pc-bios/meson.build | 2 ++
|
|
||||||
1 files changed, 2 insertions(+)
|
|
||||||
|
|
||||||
diff --git a/pc-bios/meson.build b/pc-bios/meson.build
|
|
||||||
index 05e9065ad6..f2a1d111a1 100644
|
|
||||||
--- a/pc-bios/meson.build
|
|
||||||
+++ b/pc-bios/meson.build
|
|
||||||
@@ -86,6 +86,8 @@ blobs = files(
|
|
||||||
'opensbi-riscv32-generic-fw_dynamic.elf',
|
|
||||||
'opensbi-riscv64-generic-fw_dynamic.elf',
|
|
||||||
'npcm7xx_bootrom.bin',
|
|
||||||
+ 'loongarch_bios.bin',
|
|
||||||
+ 'loongarch_vars.bin',
|
|
||||||
)
|
|
||||||
|
|
||||||
if get_option('install_blobs')
|
|
||||||
--
|
|
||||||
2.27.0
|
|
||||||
|
|
||||||
@ -1,104 +0,0 @@
|
|||||||
From a88f2d12afb6a6b5b3d97983cea95d6088f0bf04 Mon Sep 17 00:00:00 2001
|
|
||||||
From: lixianglai <lixianglai@loongson.cn>
|
|
||||||
Date: Tue, 7 Feb 2023 07:21:17 -0500
|
|
||||||
Subject: [PATCH] Add command line.
|
|
||||||
|
|
||||||
Add loongarch command support.
|
|
||||||
|
|
||||||
Signed-off-by: lixianglai <lixianglai@loongson.cn>
|
|
||||||
---
|
|
||||||
include/sysemu/arch_init.h | 1 +
|
|
||||||
qapi/machine-target.json | 6 ++++--
|
|
||||||
qapi/machine.json | 2 +-
|
|
||||||
qapi/misc-target.json | 1 +
|
|
||||||
qemu-options.hx | 2 +-
|
|
||||||
softmmu/qdev-monitor.c | 2 +-
|
|
||||||
6 files changed, 9 insertions(+), 5 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/include/sysemu/arch_init.h b/include/sysemu/arch_init.h
|
|
||||||
index 1cf27baa7c..0907b92cd1 100644
|
|
||||||
--- a/include/sysemu/arch_init.h
|
|
||||||
+++ b/include/sysemu/arch_init.h
|
|
||||||
@@ -25,6 +25,7 @@ enum {
|
|
||||||
QEMU_ARCH_AVR = (1 << 21),
|
|
||||||
QEMU_ARCH_HEXAGON = (1 << 22),
|
|
||||||
QEMU_ARCH_SW64 = (1 << 23),
|
|
||||||
+ QEMU_ARCH_LOONGARCH64 = (1 << 24),
|
|
||||||
};
|
|
||||||
|
|
||||||
extern const uint32_t arch_type;
|
|
||||||
diff --git a/qapi/machine-target.json b/qapi/machine-target.json
|
|
||||||
index f5ec4bc172..682dc86b42 100644
|
|
||||||
--- a/qapi/machine-target.json
|
|
||||||
+++ b/qapi/machine-target.json
|
|
||||||
@@ -324,7 +324,8 @@
|
|
||||||
'TARGET_ARM',
|
|
||||||
'TARGET_I386',
|
|
||||||
'TARGET_S390X',
|
|
||||||
- 'TARGET_MIPS' ] } }
|
|
||||||
+ 'TARGET_MIPS',
|
|
||||||
+ 'TARGET_LOONGARCH64' ] } }
|
|
||||||
|
|
||||||
##
|
|
||||||
# @query-cpu-definitions:
|
|
||||||
@@ -340,4 +341,5 @@
|
|
||||||
'TARGET_ARM',
|
|
||||||
'TARGET_I386',
|
|
||||||
'TARGET_S390X',
|
|
||||||
- 'TARGET_MIPS' ] } }
|
|
||||||
+ 'TARGET_MIPS',
|
|
||||||
+ 'TARGET_LOONGARCH64' ] } }
|
|
||||||
diff --git a/qapi/machine.json b/qapi/machine.json
|
|
||||||
index 03cfb268a4..31b0350b99 100644
|
|
||||||
--- a/qapi/machine.json
|
|
||||||
+++ b/qapi/machine.json
|
|
||||||
@@ -34,7 +34,7 @@
|
|
||||||
'mips64el', 'mipsel', 'nios2', 'or1k', 'ppc',
|
|
||||||
'ppc64', 'riscv32', 'riscv64', 'rx', 's390x', 'sh4',
|
|
||||||
'sh4eb', 'sparc', 'sparc64', 'tricore',
|
|
||||||
- 'x86_64', 'xtensa', 'xtensaeb' ] }
|
|
||||||
+ 'x86_64', 'xtensa', 'xtensaeb', 'loongarch64' ] }
|
|
||||||
|
|
||||||
##
|
|
||||||
# @CpuS390State:
|
|
||||||
diff --git a/qapi/misc-target.json b/qapi/misc-target.json
|
|
||||||
index 4bc45d2474..63cebef573 100644
|
|
||||||
--- a/qapi/misc-target.json
|
|
||||||
+++ b/qapi/misc-target.json
|
|
||||||
@@ -33,6 +33,7 @@
|
|
||||||
'TARGET_PPC64',
|
|
||||||
'TARGET_S390X',
|
|
||||||
'TARGET_SH4',
|
|
||||||
+ 'TARGET_LOONGARCH64',
|
|
||||||
'TARGET_SPARC' ] } }
|
|
||||||
|
|
||||||
##
|
|
||||||
diff --git a/qemu-options.hx b/qemu-options.hx
|
|
||||||
index 047d28a357..e62bb6bebd 100644
|
|
||||||
--- a/qemu-options.hx
|
|
||||||
+++ b/qemu-options.hx
|
|
||||||
@@ -2533,7 +2533,7 @@ DEF("smbios", HAS_ARG, QEMU_OPTION_smbios,
|
|
||||||
" specify SMBIOS type 17 fields\n"
|
|
||||||
"-smbios type=41[,designation=str][,kind=str][,instance=%d][,pcidev=str]\n"
|
|
||||||
" specify SMBIOS type 41 fields\n",
|
|
||||||
- QEMU_ARCH_I386 | QEMU_ARCH_ARM)
|
|
||||||
+ QEMU_ARCH_I386 | QEMU_ARCH_ARM | QEMU_ARCH_LOONGARCH64)
|
|
||||||
SRST
|
|
||||||
``-smbios file=binary``
|
|
||||||
Load SMBIOS entry from binary file.
|
|
||||||
diff --git a/softmmu/qdev-monitor.c b/softmmu/qdev-monitor.c
|
|
||||||
index 142352b24e..4ca4e92ce2 100644
|
|
||||||
--- a/softmmu/qdev-monitor.c
|
|
||||||
+++ b/softmmu/qdev-monitor.c
|
|
||||||
@@ -62,7 +62,7 @@ typedef struct QDevAlias
|
|
||||||
QEMU_ARCH_MIPS | QEMU_ARCH_PPC | \
|
|
||||||
QEMU_ARCH_RISCV | QEMU_ARCH_SH4 | \
|
|
||||||
QEMU_ARCH_SPARC | QEMU_ARCH_XTENSA | \
|
|
||||||
- QEMU_ARCH_SW64)
|
|
||||||
+ QEMU_ARCH_SW64 | QEMU_ARCH_LOONGARCH64)
|
|
||||||
#define QEMU_ARCH_VIRTIO_CCW (QEMU_ARCH_S390X)
|
|
||||||
#define QEMU_ARCH_VIRTIO_MMIO (QEMU_ARCH_M68K)
|
|
||||||
|
|
||||||
--
|
|
||||||
2.27.0
|
|
||||||
|
|
||||||
@ -1,255 +0,0 @@
|
|||||||
From 6668690dee884342e29103b5df1ab751bb236bba Mon Sep 17 00:00:00 2001
|
|
||||||
From: lixianglai <lixianglai@loongson.cn>
|
|
||||||
Date: Tue, 7 Feb 2023 07:22:58 -0500
|
|
||||||
Subject: [PATCH] Add compile script.
|
|
||||||
|
|
||||||
Modify the compile script for loongarch.
|
|
||||||
|
|
||||||
Signed-off-by: lixianglai <lixianglai@loongson.cn>
|
|
||||||
---
|
|
||||||
.../devices/loongarch64-softmmu/default.mak | 158 ++++++++++++++++++
|
|
||||||
configs/targets/loongarch64-softmmu.mak | 3 +
|
|
||||||
configure | 5 +
|
|
||||||
meson.build | 7 +-
|
|
||||||
4 files changed, 172 insertions(+), 1 deletion(-)
|
|
||||||
create mode 100644 configs/devices/loongarch64-softmmu/default.mak
|
|
||||||
create mode 100644 configs/targets/loongarch64-softmmu.mak
|
|
||||||
|
|
||||||
diff --git a/configs/devices/loongarch64-softmmu/default.mak b/configs/devices/loongarch64-softmmu/default.mak
|
|
||||||
new file mode 100644
|
|
||||||
index 0000000000..c4cc246833
|
|
||||||
--- /dev/null
|
|
||||||
+++ b/configs/devices/loongarch64-softmmu/default.mak
|
|
||||||
@@ -0,0 +1,158 @@
|
|
||||||
+# Default configuration for loongarch-softmmu
|
|
||||||
+
|
|
||||||
+CONFIG_PCI=y
|
|
||||||
+CONFIG_ACPI_PCI=y
|
|
||||||
+# For now, CONFIG_IDE_CORE requires ISA, so we enable it here
|
|
||||||
+CONFIG_ISA_BUS=y
|
|
||||||
+CONFIG_VIRTIO_PCI=y
|
|
||||||
+
|
|
||||||
+CONFIG_VGA_PCI=y
|
|
||||||
+CONFIG_ACPI_SMBUS=y
|
|
||||||
+CONFIG_VHOST_USER_SCSI=y
|
|
||||||
+CONFIG_VHOST_USER_BLK=y
|
|
||||||
+CONFIG_VIRTIO=y
|
|
||||||
+CONFIG_VIRTIO_BALLOON=y
|
|
||||||
+CONFIG_VIRTIO_BLK=y
|
|
||||||
+CONFIG_VIRTIO_CRYPTO=y
|
|
||||||
+CONFIG_VIRTIO_GPU=y
|
|
||||||
+CONFIG_VIRTIO_INPUT=y
|
|
||||||
+CONFIG_VIRTIO_NET=y
|
|
||||||
+CONFIG_VIRTIO_RNG=y
|
|
||||||
+CONFIG_SCSI=y
|
|
||||||
+CONFIG_VIRTIO_SCSI=y
|
|
||||||
+CONFIG_VIRTIO_SERIAL=y
|
|
||||||
+
|
|
||||||
+CONFIG_USB_UHCI=y
|
|
||||||
+CONFIG_USB_OHCI=y
|
|
||||||
+CONFIG_USB_OHCI_PCI=y
|
|
||||||
+CONFIG_USB_XHCI=y
|
|
||||||
+CONFIG_USB_XHCI_NEC=y
|
|
||||||
+CONFIG_NE2000_PCI=y
|
|
||||||
+CONFIG_EEPRO100_PCI=y
|
|
||||||
+CONFIG_PCNET_PCI=y
|
|
||||||
+CONFIG_PCNET_COMMON=y
|
|
||||||
+CONFIG_AC97=y
|
|
||||||
+CONFIG_HDA=y
|
|
||||||
+CONFIG_ES1370=y
|
|
||||||
+CONFIG_SCSI=y
|
|
||||||
+CONFIG_LSI_SCSI_PCI=y
|
|
||||||
+CONFIG_VMW_PVSCSI_SCSI_PCI=y
|
|
||||||
+CONFIG_MEGASAS_SCSI_PCI=y
|
|
||||||
+CONFIG_MPTSAS_SCSI_PCI=y
|
|
||||||
+CONFIG_RTL8139_PCI=y
|
|
||||||
+CONFIG_E1000_PCI=y
|
|
||||||
+CONFIG_IDE_CORE=y
|
|
||||||
+CONFIG_IDE_QDEV=y
|
|
||||||
+CONFIG_IDE_PCI=y
|
|
||||||
+CONFIG_AHCI=y
|
|
||||||
+CONFIG_AHCI_ICH9=y
|
|
||||||
+CONFIG_ESP=y
|
|
||||||
+CONFIG_ESP_PCI=y
|
|
||||||
+CONFIG_SERIAL=y
|
|
||||||
+CONFIG_SERIAL_ISA=y
|
|
||||||
+CONFIG_SERIAL_PCI=y
|
|
||||||
+CONFIG_CAN_BUS=y
|
|
||||||
+CONFIG_CAN_SJA1000=y
|
|
||||||
+CONFIG_CAN_PCI=y
|
|
||||||
+CONFIG_USB_UHCI=y
|
|
||||||
+CONFIG_USB_OHCI=y
|
|
||||||
+CONFIG_USB_XHCI=y
|
|
||||||
+CONFIG_USB_XHCI_NEC=y
|
|
||||||
+CONFIG_NE2000_PCI=y
|
|
||||||
+CONFIG_EEPRO100_PCI=y
|
|
||||||
+CONFIG_PCNET_PCI=y
|
|
||||||
+CONFIG_PCNET_COMMON=y
|
|
||||||
+CONFIG_AC97=y
|
|
||||||
+CONFIG_HDA=y
|
|
||||||
+CONFIG_ES1370=y
|
|
||||||
+CONFIG_SCSI=y
|
|
||||||
+CONFIG_LSI_SCSI_PCI=y
|
|
||||||
+CONFIG_VMW_PVSCSI_SCSI_PCI=y
|
|
||||||
+CONFIG_MEGASAS_SCSI_PCI=y
|
|
||||||
+CONFIG_MPTSAS_SCSI_PCI=y
|
|
||||||
+CONFIG_RTL8139_PCI=y
|
|
||||||
+CONFIG_E1000_PCI=y
|
|
||||||
+CONFIG_IDE_CORE=y
|
|
||||||
+CONFIG_IDE_QDEV=y
|
|
||||||
+CONFIG_IDE_PCI=y
|
|
||||||
+CONFIG_AHCI=y
|
|
||||||
+CONFIG_ESP=y
|
|
||||||
+CONFIG_ESP_PCI=y
|
|
||||||
+CONFIG_SERIAL=y
|
|
||||||
+CONFIG_SERIAL_ISA=y
|
|
||||||
+CONFIG_SERIAL_PCI=y
|
|
||||||
+CONFIG_CAN_BUS=y
|
|
||||||
+CONFIG_CAN_SJA1000=y
|
|
||||||
+CONFIG_CAN_PCI=y
|
|
||||||
+
|
|
||||||
+CONFIG_SPICE=y
|
|
||||||
+CONFIG_QXL=y
|
|
||||||
+CONFIG_ESP=y
|
|
||||||
+CONFIG_SCSI=y
|
|
||||||
+CONFIG_VGA_ISA=y
|
|
||||||
+CONFIG_VGA_ISA_MM=y
|
|
||||||
+CONFIG_VGA_CIRRUS=y
|
|
||||||
+CONFIG_VMWARE_VGA=y
|
|
||||||
+CONFIG_VIRTIO_VGA=y
|
|
||||||
+CONFIG_SERIAL=y
|
|
||||||
+CONFIG_SERIAL_ISA=y
|
|
||||||
+CONFIG_PARALLEL=y
|
|
||||||
+CONFIG_I8254=y
|
|
||||||
+CONFIG_PCSPK=y
|
|
||||||
+CONFIG_PCKBD=y
|
|
||||||
+CONFIG_FDC=y
|
|
||||||
+CONFIG_ACPI=y
|
|
||||||
+CONFIG_ACPI_MEMORY_HOTPLUG=y
|
|
||||||
+CONFIG_ACPI_NVDIMM=y
|
|
||||||
+CONFIG_ACPI_CPU_HOTPLUG=y
|
|
||||||
+CONFIG_APM=y
|
|
||||||
+CONFIG_I8257=y
|
|
||||||
+CONFIG_PIIX4=y
|
|
||||||
+CONFIG_IDE_ISA=y
|
|
||||||
+CONFIG_IDE_PIIX=y
|
|
||||||
+CONFIG_MIPSNET=y
|
|
||||||
+CONFIG_PFLASH_CFI01=y
|
|
||||||
+CONFIG_I8259=y
|
|
||||||
+CONFIG_MC146818RTC=y
|
|
||||||
+CONFIG_ISA_TESTDEV=y
|
|
||||||
+CONFIG_EMPTY_SLOT=y
|
|
||||||
+CONFIG_I2C=y
|
|
||||||
+CONFIG_DIMM=y
|
|
||||||
+CONFIG_MEM_DEVICE=y
|
|
||||||
+
|
|
||||||
+# Arch Specified CONFIG defines
|
|
||||||
+CONFIG_IDE_VIA=y
|
|
||||||
+CONFIG_VT82C686=y
|
|
||||||
+CONFIG_RC4030=y
|
|
||||||
+CONFIG_DP8393X=y
|
|
||||||
+CONFIG_DS1225Y=y
|
|
||||||
+CONFIG_FITLOADER=y
|
|
||||||
+CONFIG_SMBIOS=y
|
|
||||||
+
|
|
||||||
+CONFIG_PCIE_PORT=y
|
|
||||||
+CONFIG_I82801B11=y
|
|
||||||
+CONFIG_XIO3130=y
|
|
||||||
+CONFIG_PCI_EXPRESS=y
|
|
||||||
+CONFIG_MSI_NONBROKEN=y
|
|
||||||
+CONFIG_IOH3420=y
|
|
||||||
+CONFIG_SD=y
|
|
||||||
+CONFIG_SDHCI=y
|
|
||||||
+CONFIG_VIRTFS=y
|
|
||||||
+CONFIG_VIRTIO_9P=y
|
|
||||||
+CONFIG_USB_EHCI=y
|
|
||||||
+CONFIG_USB_EHCI_PCI=y
|
|
||||||
+CONFIG_USB_EHCI_SYSBUS=y
|
|
||||||
+CONFIG_USB_STORAGE_BOT=y
|
|
||||||
+CONFIG_TPM_EMULATOR=y
|
|
||||||
+CONFIG_TPM_TIS=y
|
|
||||||
+CONFIG_PLATFORM_BUS=y
|
|
||||||
+CONFIG_TPM_TIS_SYSBUS=y
|
|
||||||
+CONFIG_ACPI_LOONGARCH=y
|
|
||||||
+CONFIG_LS7A_RTC=y
|
|
||||||
+
|
|
||||||
+#vfio config
|
|
||||||
+CONFIG_VFIO=y
|
|
||||||
+CONFIG_VFIO_PCI=y
|
|
||||||
+CONFIG_VFIO_PLATFORM=y
|
|
||||||
+CONFIG_VFIO_XGMAC=y
|
|
||||||
+CONFIG_VFIO_AMD_XGBE=y
|
|
||||||
diff --git a/configs/targets/loongarch64-softmmu.mak b/configs/targets/loongarch64-softmmu.mak
|
|
||||||
new file mode 100644
|
|
||||||
index 0000000000..c42dfbbd9c
|
|
||||||
--- /dev/null
|
|
||||||
+++ b/configs/targets/loongarch64-softmmu.mak
|
|
||||||
@@ -0,0 +1,3 @@
|
|
||||||
+TARGET_ARCH=loongarch64
|
|
||||||
+TARGET_SUPPORTS_MTTCG=y
|
|
||||||
+TARGET_XML_FILES= gdb-xml/loongarch-base64.xml gdb-xml/loongarch-fpu.xml
|
|
||||||
diff --git a/configure b/configure
|
|
||||||
index 2576d1c693..a84dc891cc 100755
|
|
||||||
--- a/configure
|
|
||||||
+++ b/configure
|
|
||||||
@@ -579,6 +579,8 @@ elif check_define __arm__ ; then
|
|
||||||
cpu="arm"
|
|
||||||
elif check_define __aarch64__ ; then
|
|
||||||
cpu="aarch64"
|
|
||||||
+elif check_define __loongarch__ ; then
|
|
||||||
+ cpu="loongarch64"
|
|
||||||
else
|
|
||||||
cpu=$(uname -m)
|
|
||||||
fi
|
|
||||||
@@ -604,6 +606,9 @@ case "$cpu" in
|
|
||||||
aarch64)
|
|
||||||
cpu="aarch64"
|
|
||||||
;;
|
|
||||||
+ loongarch64)
|
|
||||||
+ cpu="loongarch64"
|
|
||||||
+ ;;
|
|
||||||
mips*)
|
|
||||||
cpu="mips"
|
|
||||||
;;
|
|
||||||
diff --git a/meson.build b/meson.build
|
|
||||||
index d0bbceffe1..d80426b3e8 100644
|
|
||||||
--- a/meson.build
|
|
||||||
+++ b/meson.build
|
|
||||||
@@ -56,7 +56,7 @@ python = import('python').find_installation()
|
|
||||||
|
|
||||||
supported_oses = ['windows', 'freebsd', 'netbsd', 'openbsd', 'darwin', 'sunos', 'linux']
|
|
||||||
supported_cpus = ['ppc', 'ppc64', 's390x', 'riscv', 'x86', 'x86_64',
|
|
||||||
- 'arm', 'aarch64', 'mips', 'mips64', 'sparc', 'sparc64', 'sw64']
|
|
||||||
+ 'arm', 'aarch64', 'mips', 'mips64', 'sparc', 'sparc64', 'sw64', 'loongarch64']
|
|
||||||
|
|
||||||
cpu = host_machine.cpu_family()
|
|
||||||
|
|
||||||
@@ -83,6 +83,8 @@ elif cpu in ['mips', 'mips64']
|
|
||||||
kvm_targets = ['mips-softmmu', 'mipsel-softmmu', 'mips64-softmmu', 'mips64el-softmmu']
|
|
||||||
elif cpu == 'sw64'
|
|
||||||
kvm_targets = ['sw64-softmmu']
|
|
||||||
+elif cpu == 'loongarch64'
|
|
||||||
+ kvm_targets = ['loongarch64-softmmu']
|
|
||||||
else
|
|
||||||
kvm_targets = []
|
|
||||||
endif
|
|
||||||
@@ -367,6 +369,8 @@ if not get_option('tcg').disabled()
|
|
||||||
tcg_arch = 'ppc'
|
|
||||||
elif config_host['ARCH'] in ['sw64']
|
|
||||||
tcg_arch = 'sw64'
|
|
||||||
+ elif config_host['ARCH'] == 'loongarch64'
|
|
||||||
+ tcg_arch = 'loongarch64'
|
|
||||||
endif
|
|
||||||
add_project_arguments('-iquote', meson.current_source_dir() / 'tcg' / tcg_arch,
|
|
||||||
language: ['c', 'cpp', 'objc'])
|
|
||||||
@@ -1822,6 +1826,7 @@ disassemblers = {
|
|
||||||
'sh4' : ['CONFIG_SH4_DIS'],
|
|
||||||
'sparc' : ['CONFIG_SPARC_DIS'],
|
|
||||||
'xtensa' : ['CONFIG_XTENSA_DIS'],
|
|
||||||
+ 'loongarch64' : ['CONFIG_LOONGARCH_DIS'],
|
|
||||||
'sw64' : ['CONFIG_SW64_DIS'],
|
|
||||||
}
|
|
||||||
if link_language == 'cpp'
|
|
||||||
--
|
|
||||||
2.27.0
|
|
||||||
|
|
||||||
2882
Add-disas-gdb.patch
2882
Add-disas-gdb.patch
File diff suppressed because it is too large
Load Diff
@ -1,84 +0,0 @@
|
|||||||
From 48f112e0b8e65fccc3bf66510fafb6e9a8d58e90 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Luo Yifan <luoyifan_yewu@cmss.chinamobile.com>
|
|
||||||
Date: Mon, 4 Dec 2023 10:50:04 +0800
|
|
||||||
Subject: [PATCH] Add dummy Aspeed AST2600 Display Port MCU (DPMCU)
|
|
||||||
MIME-Version: 1.0
|
|
||||||
Content-Type: text/plain; charset=UTF-8
|
|
||||||
Content-Transfer-Encoding: 8bit
|
|
||||||
|
|
||||||
cherry picked from commit d9e9cd59df4bc92e4cf7ad1bfa6e2a8429ff31b4
|
|
||||||
|
|
||||||
AST2600 Display Port MCU introduces 0x18000000~0x1803FFFF as it's memory
|
|
||||||
and io address. If guest machine try to access DPMCU memory, it will
|
|
||||||
cause a fatal error.
|
|
||||||
|
|
||||||
Signed-off-by: Troy Lee <troy_lee@aspeedtech.com>
|
|
||||||
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
|
|
||||||
Reviewed-by: Cédric Le Goater <clg@kaod.org>
|
|
||||||
Message-id: 20211210083034.726610-1-troy_lee@aspeedtech.com
|
|
||||||
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
|
|
||||||
Signed-off-by: Luo Yifan <luoyifan_yewu@cmss.chinamobile.com>
|
|
||||||
---
|
|
||||||
hw/arm/aspeed_ast2600.c | 8 ++++++++
|
|
||||||
include/hw/arm/aspeed_soc.h | 2 ++
|
|
||||||
2 files changed, 10 insertions(+)
|
|
||||||
|
|
||||||
diff --git a/hw/arm/aspeed_ast2600.c b/hw/arm/aspeed_ast2600.c
|
|
||||||
index 0384357a95..e33483fb5d 100644
|
|
||||||
--- a/hw/arm/aspeed_ast2600.c
|
|
||||||
+++ b/hw/arm/aspeed_ast2600.c
|
|
||||||
@@ -19,9 +19,11 @@
|
|
||||||
#include "sysemu/sysemu.h"
|
|
||||||
|
|
||||||
#define ASPEED_SOC_IOMEM_SIZE 0x00200000
|
|
||||||
+#define ASPEED_SOC_DPMCU_SIZE 0x00040000
|
|
||||||
|
|
||||||
static const hwaddr aspeed_soc_ast2600_memmap[] = {
|
|
||||||
[ASPEED_DEV_SRAM] = 0x10000000,
|
|
||||||
+ [ASPEED_DEV_DPMCU] = 0x18000000,
|
|
||||||
/* 0x16000000 0x17FFFFFF : AHB BUS do LPC Bus bridge */
|
|
||||||
[ASPEED_DEV_IOMEM] = 0x1E600000,
|
|
||||||
[ASPEED_DEV_PWM] = 0x1E610000,
|
|
||||||
@@ -44,6 +46,7 @@ static const hwaddr aspeed_soc_ast2600_memmap[] = {
|
|
||||||
[ASPEED_DEV_SCU] = 0x1E6E2000,
|
|
||||||
[ASPEED_DEV_XDMA] = 0x1E6E7000,
|
|
||||||
[ASPEED_DEV_ADC] = 0x1E6E9000,
|
|
||||||
+ [ASPEED_DEV_DP] = 0x1E6EB000,
|
|
||||||
[ASPEED_DEV_VIDEO] = 0x1E700000,
|
|
||||||
[ASPEED_DEV_SDHCI] = 0x1E740000,
|
|
||||||
[ASPEED_DEV_EMMC] = 0x1E750000,
|
|
||||||
@@ -104,6 +107,7 @@ static const int aspeed_soc_ast2600_irqmap[] = {
|
|
||||||
[ASPEED_DEV_ETH3] = 32,
|
|
||||||
[ASPEED_DEV_ETH4] = 33,
|
|
||||||
[ASPEED_DEV_KCS] = 138, /* 138 -> 142 */
|
|
||||||
+ [ASPEED_DEV_DP] = 62,
|
|
||||||
};
|
|
||||||
|
|
||||||
static qemu_irq aspeed_soc_get_irq(AspeedSoCState *s, int ctrl)
|
|
||||||
@@ -298,6 +302,10 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp)
|
|
||||||
memory_region_add_subregion(get_system_memory(),
|
|
||||||
sc->memmap[ASPEED_DEV_SRAM], &s->sram);
|
|
||||||
|
|
||||||
+ /* DPMCU */
|
|
||||||
+ create_unimplemented_device("aspeed.dpmcu", sc->memmap[ASPEED_DEV_DPMCU],
|
|
||||||
+ ASPEED_SOC_DPMCU_SIZE);
|
|
||||||
+
|
|
||||||
/* SCU */
|
|
||||||
if (!sysbus_realize(SYS_BUS_DEVICE(&s->scu), errp)) {
|
|
||||||
return;
|
|
||||||
diff --git a/include/hw/arm/aspeed_soc.h b/include/hw/arm/aspeed_soc.h
|
|
||||||
index 8139358549..18fb7eed46 100644
|
|
||||||
--- a/include/hw/arm/aspeed_soc.h
|
|
||||||
+++ b/include/hw/arm/aspeed_soc.h
|
|
||||||
@@ -139,6 +139,8 @@ enum {
|
|
||||||
ASPEED_DEV_EMMC,
|
|
||||||
ASPEED_DEV_KCS,
|
|
||||||
ASPEED_DEV_HACE,
|
|
||||||
+ ASPEED_DEV_DPMCU,
|
|
||||||
+ ASPEED_DEV_DP,
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif /* ASPEED_SOC_H */
|
|
||||||
--
|
|
||||||
2.27.0
|
|
||||||
|
|
||||||
@ -1,35 +0,0 @@
|
|||||||
From 96df1be5fee763f54db9f50466f4ccf433c48ea1 Mon Sep 17 00:00:00 2001
|
|
||||||
From: jianchunfu <jianchunfu_yewu@cmss.chinamobile.com>
|
|
||||||
Date: Wed, 30 Nov 2022 14:33:12 +0800
|
|
||||||
Subject: [PATCH 03/17] Add flex/bison to `debian-hexagon-cross`
|
|
||||||
|
|
||||||
debian-hexagon-cross contains two images, one to build the toolchain
|
|
||||||
used for building the Hexagon tests themselves, and one image to build
|
|
||||||
QEMU and run the tests.
|
|
||||||
This commit adds flex/bison to the final image that builds QEMU so that
|
|
||||||
it can also build idef-parser.
|
|
||||||
Note: This container is not built by the CI and needs to be rebuilt and
|
|
||||||
updated manually.
|
|
||||||
|
|
||||||
Signed-off-by: Anton Johansson <anjo@rev.ng>
|
|
||||||
Signed-off-by: jianchunfu <jianchunfu_yewu@cmss.chinamobile.com>
|
|
||||||
---
|
|
||||||
tests/docker/dockerfiles/debian-hexagon-cross.docker | 2 +-
|
|
||||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
|
||||||
|
|
||||||
diff --git a/tests/docker/dockerfiles/debian-hexagon-cross.docker b/tests/docker/dockerfiles/debian-hexagon-cross.docker
|
|
||||||
index d5dc299dc1..a64e950f07 100644
|
|
||||||
--- a/tests/docker/dockerfiles/debian-hexagon-cross.docker
|
|
||||||
+++ b/tests/docker/dockerfiles/debian-hexagon-cross.docker
|
|
||||||
@@ -38,7 +38,7 @@ RUN cat /etc/apt/sources.list | sed "s/^deb\ /deb-src /" >> /etc/apt/sources.lis
|
|
||||||
# Install QEMU build deps for use in CI
|
|
||||||
RUN apt update && \
|
|
||||||
DEBIAN_FRONTEND=noninteractive apt install -yy eatmydata && \
|
|
||||||
- DEBIAN_FRONTEND=noninteractive eatmydata apt install -yy git ninja-build && \
|
|
||||||
+ DEBIAN_FRONTEND=noninteractive eatmydata apt install -yy bison flex git ninja-build && \
|
|
||||||
DEBIAN_FRONTEND=noninteractive eatmydata \
|
|
||||||
apt build-dep -yy --arch-only qemu
|
|
||||||
COPY --from=0 /usr/local /usr/local
|
|
||||||
--
|
|
||||||
2.27.0
|
|
||||||
|
|
||||||
@ -1,160 +0,0 @@
|
|||||||
From c174f8c60cd372301200cdecaaae345b079cf589 Mon Sep 17 00:00:00 2001
|
|
||||||
From: lixianglai <lixianglai@loongson.cn>
|
|
||||||
Date: Wed, 24 May 2023 23:28:41 -0400
|
|
||||||
Subject: [PATCH] Add lbt support for kvm.
|
|
||||||
|
|
||||||
Add lbt registers get and put function.
|
|
||||||
|
|
||||||
Signed-off-by: lixianglai <lixianglai@loongson.cn>
|
|
||||||
---
|
|
||||||
hw/loongarch/larch_3a.c | 3 ++-
|
|
||||||
linux-headers/asm-loongarch64/kvm.h | 15 +++++++++++++
|
|
||||||
target/loongarch64/cpu.h | 10 +++++++++
|
|
||||||
target/loongarch64/kvm.c | 35 +++++++++++++++++++++++++++++
|
|
||||||
4 files changed, 62 insertions(+), 1 deletion(-)
|
|
||||||
|
|
||||||
diff --git a/hw/loongarch/larch_3a.c b/hw/loongarch/larch_3a.c
|
|
||||||
index cef1a6f3d2..95bb224664 100644
|
|
||||||
--- a/hw/loongarch/larch_3a.c
|
|
||||||
+++ b/hw/loongarch/larch_3a.c
|
|
||||||
@@ -356,7 +356,8 @@ struct kvm_cpucfg ls3a5k_cpucfgs = {
|
|
||||||
.cpucfg[LOONGARCH_CPUCFG2] =
|
|
||||||
CPUCFG2_FP | CPUCFG2_FPSP | CPUCFG2_FPDP | CPUCFG2_FPVERS |
|
|
||||||
CPUCFG2_LSX | CPUCFG2_LASX | CPUCFG2_COMPLEX | CPUCFG2_CRYPTO |
|
|
||||||
- CPUCFG2_LLFTP | CPUCFG2_LLFTPREV | CPUCFG2_LSPW | CPUCFG2_LAM,
|
|
||||||
+ CPUCFG2_LLFTP | CPUCFG2_LLFTPREV | CPUCFG2_X86BT | CPUCFG2_ARMBT |
|
|
||||||
+ CPUCFG2_MIPSBT | CPUCFG2_LSPW | CPUCFG2_LAM,
|
|
||||||
.cpucfg[LOONGARCH_CPUCFG3] =
|
|
||||||
CPUCFG3_CCDMA | CPUCFG3_SFB | CPUCFG3_UCACC | CPUCFG3_LLEXC |
|
|
||||||
CPUCFG3_SCDLY | CPUCFG3_LLDBAR | CPUCFG3_ITLBT | CPUCFG3_ICACHET |
|
|
||||||
diff --git a/linux-headers/asm-loongarch64/kvm.h b/linux-headers/asm-loongarch64/kvm.h
|
|
||||||
index a473916d50..a036ea57cd 100644
|
|
||||||
--- a/linux-headers/asm-loongarch64/kvm.h
|
|
||||||
+++ b/linux-headers/asm-loongarch64/kvm.h
|
|
||||||
@@ -82,6 +82,7 @@ struct kvm_fpu {
|
|
||||||
* Register set = 2: KVM specific registers (see definitions below).
|
|
||||||
*
|
|
||||||
* Register set = 3: FPU / MSA registers (see definitions below).
|
|
||||||
+ * Register set = 4: LBT registers (see definitions below).
|
|
||||||
*
|
|
||||||
* Other sets registers may be added in the future. Each set would
|
|
||||||
* have its own identifier in bits[31..16].
|
|
||||||
@@ -91,6 +92,7 @@ struct kvm_fpu {
|
|
||||||
#define KVM_REG_LOONGARCH_CSR (KVM_REG_LOONGARCH | 0x0000000000010000ULL)
|
|
||||||
#define KVM_REG_LOONGARCH_KVM (KVM_REG_LOONGARCH | 0x0000000000020000ULL)
|
|
||||||
#define KVM_REG_LOONGARCH_FPU (KVM_REG_LOONGARCH | 0x0000000000030000ULL)
|
|
||||||
+#define KVM_REG_LOONGARCH_LBT (KVM_REG_LOONGARCH | 0x0000000000040000ULL)
|
|
||||||
|
|
||||||
/*
|
|
||||||
* KVM_REG_LOONGARCH_GP - General purpose registers from kvm_regs.
|
|
||||||
@@ -174,6 +176,19 @@ struct kvm_fpu {
|
|
||||||
#define KVM_REG_LOONGARCH_VCPU_RESET \
|
|
||||||
(KVM_REG_LOONGARCH_KVM | KVM_REG_SIZE_U64 | 4)
|
|
||||||
|
|
||||||
+#define KVM_REG_LBT_SCR0 \
|
|
||||||
+ (KVM_REG_LOONGARCH_LBT | KVM_REG_SIZE_U64 | 1)
|
|
||||||
+#define KVM_REG_LBT_SCR1 \
|
|
||||||
+ (KVM_REG_LOONGARCH_LBT | KVM_REG_SIZE_U64 | 2)
|
|
||||||
+#define KVM_REG_LBT_SCR2 \
|
|
||||||
+ (KVM_REG_LOONGARCH_LBT | KVM_REG_SIZE_U64 | 3)
|
|
||||||
+#define KVM_REG_LBT_SCR3 \
|
|
||||||
+ (KVM_REG_LOONGARCH_LBT | KVM_REG_SIZE_U64 | 4)
|
|
||||||
+#define KVM_REG_LBT_FLAGS \
|
|
||||||
+ (KVM_REG_LOONGARCH_LBT | KVM_REG_SIZE_U64 | 5)
|
|
||||||
+#define KVM_REG_LBT_FTOP \
|
|
||||||
+ (KVM_REG_LOONGARCH_LBT | KVM_REG_SIZE_U64 | 6)
|
|
||||||
+
|
|
||||||
struct kvm_iocsr_entry {
|
|
||||||
__u32 addr;
|
|
||||||
__u32 pad;
|
|
||||||
diff --git a/target/loongarch64/cpu.h b/target/loongarch64/cpu.h
|
|
||||||
index bf5b36d404..8a29a507b1 100644
|
|
||||||
--- a/target/loongarch64/cpu.h
|
|
||||||
+++ b/target/loongarch64/cpu.h
|
|
||||||
@@ -75,6 +75,7 @@ typedef struct CPULOONGARCHFPUContext {
|
|
||||||
uint32_t fcsr0;
|
|
||||||
uint32_t fcsr0_rw_bitmask;
|
|
||||||
uint32_t vcsr16;
|
|
||||||
+ uint64_t ftop;
|
|
||||||
} CPULOONGARCHFPUContext;
|
|
||||||
|
|
||||||
/* fp control and status register definition */
|
|
||||||
@@ -196,6 +197,15 @@ struct CPULOONGARCHState {
|
|
||||||
struct {
|
|
||||||
uint64_t guest_addr;
|
|
||||||
} st;
|
|
||||||
+ struct {
|
|
||||||
+ /* scratch registers */
|
|
||||||
+ unsigned long scr0;
|
|
||||||
+ unsigned long scr1;
|
|
||||||
+ unsigned long scr2;
|
|
||||||
+ unsigned long scr3;
|
|
||||||
+ /* loongarch eflag */
|
|
||||||
+ unsigned long eflag;
|
|
||||||
+ } lbt;
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
diff --git a/target/loongarch64/kvm.c b/target/loongarch64/kvm.c
|
|
||||||
index 21f6d5695f..0a4dc86421 100644
|
|
||||||
--- a/target/loongarch64/kvm.c
|
|
||||||
+++ b/target/loongarch64/kvm.c
|
|
||||||
@@ -1277,6 +1277,39 @@ int kvm_loongarch_get_pvtime(LOONGARCHCPU *cpu)
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
+
|
|
||||||
+static int kvm_loongarch_put_lbt_registers(CPUState *cs)
|
|
||||||
+{
|
|
||||||
+ int ret = 0;
|
|
||||||
+ LOONGARCHCPU *cpu = LOONGARCH_CPU(cs);
|
|
||||||
+ CPULOONGARCHState *env = &cpu->env;
|
|
||||||
+
|
|
||||||
+ ret |= kvm_larch_putq(cs, KVM_REG_LBT_SCR0, &env->lbt.scr0);
|
|
||||||
+ ret |= kvm_larch_putq(cs, KVM_REG_LBT_SCR1, &env->lbt.scr1);
|
|
||||||
+ ret |= kvm_larch_putq(cs, KVM_REG_LBT_SCR2, &env->lbt.scr2);
|
|
||||||
+ ret |= kvm_larch_putq(cs, KVM_REG_LBT_SCR3, &env->lbt.scr3);
|
|
||||||
+ ret |= kvm_larch_putq(cs, KVM_REG_LBT_FLAGS, &env->lbt.eflag);
|
|
||||||
+ ret |= kvm_larch_putq(cs, KVM_REG_LBT_FTOP, &env->active_fpu.ftop);
|
|
||||||
+
|
|
||||||
+ return ret;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+static int kvm_loongarch_get_lbt_registers(CPUState *cs)
|
|
||||||
+{
|
|
||||||
+ int ret = 0;
|
|
||||||
+ LOONGARCHCPU *cpu = LOONGARCH_CPU(cs);
|
|
||||||
+ CPULOONGARCHState *env = &cpu->env;
|
|
||||||
+
|
|
||||||
+ ret |= kvm_larch_getq(cs, KVM_REG_LBT_SCR0, &env->lbt.scr0);
|
|
||||||
+ ret |= kvm_larch_getq(cs, KVM_REG_LBT_SCR1, &env->lbt.scr1);
|
|
||||||
+ ret |= kvm_larch_getq(cs, KVM_REG_LBT_SCR2, &env->lbt.scr2);
|
|
||||||
+ ret |= kvm_larch_getq(cs, KVM_REG_LBT_SCR3, &env->lbt.scr3);
|
|
||||||
+ ret |= kvm_larch_getq(cs, KVM_REG_LBT_FLAGS, &env->lbt.eflag);
|
|
||||||
+ ret |= kvm_larch_getq(cs, KVM_REG_LBT_FTOP, &env->active_fpu.ftop);
|
|
||||||
+
|
|
||||||
+ return ret;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
int kvm_arch_put_registers(CPUState *cs, int level)
|
|
||||||
{
|
|
||||||
LOONGARCHCPU *cpu = LOONGARCH_CPU(cs);
|
|
||||||
@@ -1308,6 +1341,7 @@ int kvm_arch_put_registers(CPUState *cs, int level)
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
+ kvm_loongarch_put_lbt_registers(cs);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1334,6 +1368,7 @@ int kvm_arch_get_registers(CPUState *cs)
|
|
||||||
|
|
||||||
kvm_loongarch_get_csr_registers(cs);
|
|
||||||
kvm_loongarch_get_fpu_registers(cs);
|
|
||||||
+ kvm_loongarch_get_lbt_registers(cs);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
--
|
|
||||||
2.41.0.windows.1
|
|
||||||
|
|
||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
3009
Add-tcg.patch
3009
Add-tcg.patch
File diff suppressed because it is too large
Load Diff
@ -1,48 +0,0 @@
|
|||||||
From baf464ea0c35f9b235e8385b0771392ce362a6ec Mon Sep 17 00:00:00 2001
|
|
||||||
From: tangbinzy <tangbin_yewu@cmss.chinamobile.com>
|
|
||||||
Date: Fri, 21 Jul 2023 06:14:37 +0000
|
|
||||||
Subject: [PATCH] Allow setting up to 8 bytes with the generic loader mainline
|
|
||||||
inclusion commit f42483d776bce29a9925ed61cc10eb27a5b2446c category: bugfix
|
|
||||||
MIME-Version: 1.0
|
|
||||||
Content-Type: text/plain; charset=UTF-8
|
|
||||||
Content-Transfer-Encoding: 8bit
|
|
||||||
|
|
||||||
---------------------------------------------------------------
|
|
||||||
|
|
||||||
The documentation for the generic loader says that "the maximum size of
|
|
||||||
the data is 8 bytes". However, attempts to set data-len=8 trigger the
|
|
||||||
following assertion failure:
|
|
||||||
|
|
||||||
../hw/core/generic-loader.c:59: generic_loader_reset: Assertion `s->data_len < sizeof(s->data)' failed.
|
|
||||||
|
|
||||||
The type of s->data is uint64_t (i.e. 8 bytes long), so I believe this
|
|
||||||
assert should use <= instead of <.
|
|
||||||
|
|
||||||
Fixes: e481a1f63c93 ("generic-loader: Add a generic loader")
|
|
||||||
Signed-off-by: Petr Tesarik <ptesarik@suse.com>
|
|
||||||
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
|
|
||||||
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
|
|
||||||
Message-id: 20220120092715.7805-1-ptesarik@suse.com
|
|
||||||
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
|
|
||||||
|
|
||||||
Signed-off-by: tangbinzy <tangbin_yewu@cmss.chinamobile.com>
|
|
||||||
---
|
|
||||||
hw/core/generic-loader.c | 2 +-
|
|
||||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
|
||||||
|
|
||||||
diff --git a/hw/core/generic-loader.c b/hw/core/generic-loader.c
|
|
||||||
index 9a24ffb880..504ed7ca72 100644
|
|
||||||
--- a/hw/core/generic-loader.c
|
|
||||||
+++ b/hw/core/generic-loader.c
|
|
||||||
@@ -56,7 +56,7 @@ static void generic_loader_reset(void *opaque)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (s->data_len) {
|
|
||||||
- assert(s->data_len < sizeof(s->data));
|
|
||||||
+ assert(s->data_len <= sizeof(s->data));
|
|
||||||
dma_memory_write(s->cpu->as, s->addr, &s->data, s->data_len,
|
|
||||||
MEMTXATTRS_UNSPECIFIED);
|
|
||||||
}
|
|
||||||
--
|
|
||||||
2.41.0.windows.1
|
|
||||||
|
|
||||||
BIN
BinDir.tar.gz
BIN
BinDir.tar.gz
Binary file not shown.
@ -1,49 +0,0 @@
|
|||||||
From c24b649580f7eeb656124fabe255760829d01408 Mon Sep 17 00:00:00 2001
|
|
||||||
From: tangbinzy <tangbin_yewu@cmss.chinamobile.com>
|
|
||||||
Date: Wed, 26 Jul 2023 13:37:41 +0000
|
|
||||||
Subject: [PATCH] Check and report for incomplete 'global' option format
|
|
||||||
mainline inclusion commit 818e1636080768749dc826acd4825e71828ec7e6 category:
|
|
||||||
bugfix
|
|
||||||
|
|
||||||
---------------------------------------------------------------
|
|
||||||
|
|
||||||
Qemu might crash when provided incomplete '-global' option.
|
|
||||||
For example:
|
|
||||||
qemu-system-x86_64 -global driver=isa-fdc
|
|
||||||
qemu-system-x86_64: ../../devel/qemu/qapi/string-input-visitor.c:394:
|
|
||||||
string_input_visitor_new: Assertion `str' failed.
|
|
||||||
Aborted (core dumped)
|
|
||||||
|
|
||||||
Fixes: 3751d7c43f795b ("vl: allow full-blown QemuOpts syntax for -global")
|
|
||||||
Signed-off-by: Rohit Kumar <rohit.kumar3@nutanix.com>
|
|
||||||
Reviewed-by: Markus Armbruster <armbru@redhat.com>
|
|
||||||
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/604
|
|
||||||
Message-Id: <20220216071508.412974-1-rohit.kumar3@nutanix.com>
|
|
||||||
Signed-off-by: Thomas Huth <thuth@redhat.com>
|
|
||||||
|
|
||||||
Signed-off-by: tangbinzy <tangbin_yewu@cmss.chinamobile.com>
|
|
||||||
---
|
|
||||||
softmmu/qdev-monitor.c | 7 +++++++
|
|
||||||
1 file changed, 7 insertions(+)
|
|
||||||
|
|
||||||
diff --git a/softmmu/qdev-monitor.c b/softmmu/qdev-monitor.c
|
|
||||||
index 4ca4e92ce2..14efb37014 100644
|
|
||||||
--- a/softmmu/qdev-monitor.c
|
|
||||||
+++ b/softmmu/qdev-monitor.c
|
|
||||||
@@ -1041,6 +1041,13 @@ int qemu_global_option(const char *str)
|
|
||||||
if (!opts) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
+ if (!qemu_opt_get(opts, "driver")
|
|
||||||
+ || !qemu_opt_get(opts, "property")
|
|
||||||
+ || !qemu_opt_get(opts, "value")) {
|
|
||||||
+ error_report("options 'driver', 'property', and 'value'"
|
|
||||||
+ " are required");
|
|
||||||
+ return -1;
|
|
||||||
+ }
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
--
|
|
||||||
2.41.0.windows.1
|
|
||||||
|
|
||||||
@ -1,27 +0,0 @@
|
|||||||
From 9e2158495059b485f2c28bb649c8b4a87fb3105c Mon Sep 17 00:00:00 2001
|
|
||||||
From: Chuan Zheng <zhengchuan@huawei.com>
|
|
||||||
Date: Wed, 9 Feb 2022 11:24:32 +0800
|
|
||||||
Subject: [PATCH 12/15] Currently, while kvm and qemu can not handle some kvm
|
|
||||||
exit, qemu will do vm_stop, which will make vm in pause state. This action
|
|
||||||
make vm unrecoverable, so send guest panic to libvirt instead.
|
|
||||||
|
|
||||||
---
|
|
||||||
accel/kvm/kvm-all.c | 2 +-
|
|
||||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
|
||||||
|
|
||||||
diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
|
|
||||||
index eecd8031cf..b128d311c2 100644
|
|
||||||
--- a/accel/kvm/kvm-all.c
|
|
||||||
+++ b/accel/kvm/kvm-all.c
|
|
||||||
@@ -2970,7 +2970,7 @@ int kvm_cpu_exec(CPUState *cpu)
|
|
||||||
|
|
||||||
if (ret < 0) {
|
|
||||||
cpu_dump_state(cpu, stderr, CPU_DUMP_CODE);
|
|
||||||
- vm_stop(RUN_STATE_INTERNAL_ERROR);
|
|
||||||
+ qemu_system_guest_panicked(cpu_get_crash_info(cpu));
|
|
||||||
}
|
|
||||||
|
|
||||||
qatomic_set(&cpu->exit_request, 0);
|
|
||||||
--
|
|
||||||
2.27.0
|
|
||||||
|
|
||||||
@ -1,43 +0,0 @@
|
|||||||
From 8733b8a26407177b867d3293283c257efeb784a0 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Luo Yifan <luoyifan_yewu@cmss.chinamobile.com>
|
|
||||||
Date: Fri, 1 Dec 2023 12:51:56 +0800
|
|
||||||
Subject: [PATCH] Fix STM32F2XX USART data register readout
|
|
||||||
MIME-Version: 1.0
|
|
||||||
Content-Type: text/plain; charset=UTF-8
|
|
||||||
Content-Transfer-Encoding: 8bit
|
|
||||||
|
|
||||||
cherry picked from commit ab08c3467605365b44fab1b66bb6254db86814f6
|
|
||||||
|
|
||||||
Fix issue where the data register may be overwritten by next character
|
|
||||||
reception before being read and returned.
|
|
||||||
|
|
||||||
Signed-off-by: Olivier Hériveaux <olivier.heriveaux@ledger.fr>
|
|
||||||
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
|
|
||||||
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
|
|
||||||
Message-id: 20211128120723.4053-1-olivier.heriveaux@ledger.fr
|
|
||||||
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
|
|
||||||
Signed-off-by: Luo Yifan <luoyifan_yewu@cmss.chinamobile.com>
|
|
||||||
---
|
|
||||||
hw/char/stm32f2xx_usart.c | 3 ++-
|
|
||||||
1 file changed, 2 insertions(+), 1 deletion(-)
|
|
||||||
|
|
||||||
diff --git a/hw/char/stm32f2xx_usart.c b/hw/char/stm32f2xx_usart.c
|
|
||||||
index 8df0832424..fde67f4f03 100644
|
|
||||||
--- a/hw/char/stm32f2xx_usart.c
|
|
||||||
+++ b/hw/char/stm32f2xx_usart.c
|
|
||||||
@@ -103,10 +103,11 @@ static uint64_t stm32f2xx_usart_read(void *opaque, hwaddr addr,
|
|
||||||
return retvalue;
|
|
||||||
case USART_DR:
|
|
||||||
DB_PRINT("Value: 0x%" PRIx32 ", %c\n", s->usart_dr, (char) s->usart_dr);
|
|
||||||
+ retvalue = s->usart_dr & 0x3FF;
|
|
||||||
s->usart_sr &= ~USART_SR_RXNE;
|
|
||||||
qemu_chr_fe_accept_input(&s->chr);
|
|
||||||
qemu_set_irq(s->irq, 0);
|
|
||||||
- return s->usart_dr & 0x3FF;
|
|
||||||
+ return retvalue;
|
|
||||||
case USART_BRR:
|
|
||||||
return s->usart_brr;
|
|
||||||
case USART_CR1:
|
|
||||||
--
|
|
||||||
2.27.0
|
|
||||||
|
|
||||||
@ -1,140 +0,0 @@
|
|||||||
From 961450f0cf1e2e3a092dd723d7c63a310a881e93 Mon Sep 17 00:00:00 2001
|
|
||||||
From: wangjinlei <wangjinlei_yewu@cmss.chinamobile.com>
|
|
||||||
Date: Wed, 23 Nov 2022 14:37:06 +0800
|
|
||||||
Subject: [PATCH 10/29] Fix several typos in documentation (found by codespell)
|
|
||||||
MIME-Version: 1.0
|
|
||||||
Content-Type: text/plain; charset=UTF-8
|
|
||||||
Content-Transfer-Encoding: 8bit
|
|
||||||
|
|
||||||
Those typos are in files which are used to generate the QEMU manual.
|
|
||||||
|
|
||||||
Signed-off-by: Stefan Weil <sw@weilnetz.de>
|
|
||||||
Message-Id: <20221110190825.879620-1-sw@weilnetz.de>
|
|
||||||
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
|
|
||||||
Reviewed-by: Ani Sinha <ani@anisinha.ca>
|
|
||||||
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
|
|
||||||
Acked-by: Michael S. Tsirkin <mst@redhat.com>
|
|
||||||
[thuth: update sentence in can.rst as suggested by Peter]
|
|
||||||
Signed-off-by: Thomas Huth <thuth@redhat.com>
|
|
||||||
Signed-off-by: wangjinlei <wangjinlei_yewu@cmss.chinamobile.com>
|
|
||||||
---
|
|
||||||
hw/scsi/esp.c | 6 +++---
|
|
||||||
include/exec/memory.h | 6 +++---
|
|
||||||
qemu-options.hx | 4 ++--
|
|
||||||
tests/qtest/libqos/qgraph.h | 2 +-
|
|
||||||
tests/qtest/libqos/virtio-9p.c | 2 +-
|
|
||||||
5 files changed, 10 insertions(+), 10 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c
|
|
||||||
index 58d0edbd56..f38231f8cd 100644
|
|
||||||
--- a/hw/scsi/esp.c
|
|
||||||
+++ b/hw/scsi/esp.c
|
|
||||||
@@ -510,7 +510,7 @@ static void do_dma_pdma_cb(ESPState *s)
|
|
||||||
} else {
|
|
||||||
/*
|
|
||||||
* Extra message out bytes received: update cmdfifo_cdb_offset
|
|
||||||
- * and then switch to commmand phase
|
|
||||||
+ * and then switch to command phase
|
|
||||||
*/
|
|
||||||
s->cmdfifo_cdb_offset = fifo8_num_used(&s->cmdfifo);
|
|
||||||
s->rregs[ESP_RSTAT] = STAT_TC | STAT_CD;
|
|
||||||
@@ -622,7 +622,7 @@ static void esp_do_dma(ESPState *s)
|
|
||||||
} else {
|
|
||||||
/*
|
|
||||||
* Extra message out bytes received: update cmdfifo_cdb_offset
|
|
||||||
- * and then switch to commmand phase
|
|
||||||
+ * and then switch to command phase
|
|
||||||
*/
|
|
||||||
s->cmdfifo_cdb_offset = fifo8_num_used(&s->cmdfifo);
|
|
||||||
s->rregs[ESP_RSTAT] = STAT_TC | STAT_CD;
|
|
||||||
@@ -733,7 +733,7 @@ static void esp_do_nodma(ESPState *s)
|
|
||||||
} else {
|
|
||||||
/*
|
|
||||||
* Extra message out bytes received: update cmdfifo_cdb_offset
|
|
||||||
- * and then switch to commmand phase
|
|
||||||
+ * and then switch to command phase
|
|
||||||
*/
|
|
||||||
s->cmdfifo_cdb_offset = fifo8_num_used(&s->cmdfifo);
|
|
||||||
s->rregs[ESP_RSTAT] = STAT_TC | STAT_CD;
|
|
||||||
diff --git a/include/exec/memory.h b/include/exec/memory.h
|
|
||||||
index 4b5b431e45..abb838f194 100644
|
|
||||||
--- a/include/exec/memory.h
|
|
||||||
+++ b/include/exec/memory.h
|
|
||||||
@@ -561,7 +561,7 @@ typedef void (*ReplayRamDiscard)(MemoryRegionSection *section, void *opaque);
|
|
||||||
* A #RamDiscardManager coordinates which parts of specific RAM #MemoryRegion
|
|
||||||
* regions are currently populated to be used/accessed by the VM, notifying
|
|
||||||
* after parts were discarded (freeing up memory) and before parts will be
|
|
||||||
- * populated (consuming memory), to be used/acessed by the VM.
|
|
||||||
+ * populated (consuming memory), to be used/accessed by the VM.
|
|
||||||
*
|
|
||||||
* A #RamDiscardManager can only be set for a RAM #MemoryRegion while the
|
|
||||||
* #MemoryRegion isn't mapped yet; it cannot change while the #MemoryRegion is
|
|
||||||
@@ -585,7 +585,7 @@ typedef void (*ReplayRamDiscard)(MemoryRegionSection *section, void *opaque);
|
|
||||||
* Listeners are called in multiples of the minimum granularity (unless it
|
|
||||||
* would exceed the registered range) and changes are aligned to the minimum
|
|
||||||
* granularity within the #MemoryRegion. Listeners have to prepare for memory
|
|
||||||
- * becomming discarded in a different granularity than it was populated and the
|
|
||||||
+ * becoming discarded in a different granularity than it was populated and the
|
|
||||||
* other way around.
|
|
||||||
*/
|
|
||||||
struct RamDiscardManagerClass {
|
|
||||||
@@ -1242,7 +1242,7 @@ void memory_region_init_ram_flags_nomigrate(MemoryRegion *mr,
|
|
||||||
Error **errp);
|
|
||||||
|
|
||||||
/**
|
|
||||||
- * memory_region_init_resizeable_ram: Initialize memory region with resizeable
|
|
||||||
+ * memory_region_init_resizeable_ram: Initialize memory region with resizable
|
|
||||||
* RAM. Accesses into the region will
|
|
||||||
* modify memory directly. Only an initial
|
|
||||||
* portion of this RAM is actually used.
|
|
||||||
diff --git a/qemu-options.hx b/qemu-options.hx
|
|
||||||
index 1aaf38c613..047d28a357 100644
|
|
||||||
--- a/qemu-options.hx
|
|
||||||
+++ b/qemu-options.hx
|
|
||||||
@@ -318,7 +318,7 @@ SRST
|
|
||||||
\
|
|
||||||
``-numa cpu,node-id=node[,socket-id=x][,core-id=y][,thread-id=z]``
|
|
||||||
\
|
|
||||||
-``-numa hmat-lb,initiator=node,target=node,hierarchy=hierarchy,data-type=tpye[,latency=lat][,bandwidth=bw]``
|
|
||||||
+``-numa hmat-lb,initiator=node,target=node,hierarchy=hierarchy,data-type=type[,latency=lat][,bandwidth=bw]``
|
|
||||||
\
|
|
||||||
``-numa hmat-cache,node-id=node,size=size,level=level[,associativity=str][,policy=str][,line=size]``
|
|
||||||
Define a NUMA node and assign RAM and VCPUs to it. Set the NUMA
|
|
||||||
@@ -1717,7 +1717,7 @@ SRST
|
|
||||||
directory on host is made directly accessible by guest as a pass-through
|
|
||||||
file system by using the 9P network protocol for communication between
|
|
||||||
host and guests, if desired even accessible, shared by several guests
|
|
||||||
- simultaniously.
|
|
||||||
+ simultaneously.
|
|
||||||
|
|
||||||
Note that ``-virtfs`` is actually just a convenience shortcut for its
|
|
||||||
generalized form ``-fsdev -device virtio-9p-pci``.
|
|
||||||
diff --git a/tests/qtest/libqos/qgraph.h b/tests/qtest/libqos/qgraph.h
|
|
||||||
index 871740c0dc..33d609a06a 100644
|
|
||||||
--- a/tests/qtest/libqos/qgraph.h
|
|
||||||
+++ b/tests/qtest/libqos/qgraph.h
|
|
||||||
@@ -381,7 +381,7 @@ QOSGraphObject *qos_driver_new(QOSGraphNode *node, QOSGraphObject *parent,
|
|
||||||
* mind: only tests with a path down from the actual test case node (leaf) up
|
|
||||||
* to the graph's root node are actually executed by the qtest framework. And
|
|
||||||
* the qtest framework uses QMP to automatically check which QEMU drivers are
|
|
||||||
- * actually currently available, and accordingly qos marks certain pathes as
|
|
||||||
+ * actually currently available, and accordingly qos marks certain paths as
|
|
||||||
* 'unavailable' in such cases (e.g. when QEMU was compiled without support for
|
|
||||||
* a certain feature).
|
|
||||||
*/
|
|
||||||
diff --git a/tests/qtest/libqos/virtio-9p.c b/tests/qtest/libqos/virtio-9p.c
|
|
||||||
index b4e1143288..2941d3cdc6 100644
|
|
||||||
--- a/tests/qtest/libqos/virtio-9p.c
|
|
||||||
+++ b/tests/qtest/libqos/virtio-9p.c
|
|
||||||
@@ -31,7 +31,7 @@
|
|
||||||
static QGuestAllocator *alloc;
|
|
||||||
static char *local_test_path;
|
|
||||||
|
|
||||||
-/* Concatenates the passed 2 pathes. Returned result must be freed. */
|
|
||||||
+/* Concatenates the passed 2 paths. Returned result must be freed. */
|
|
||||||
static char *concat_path(const char* a, const char* b)
|
|
||||||
{
|
|
||||||
return g_build_filename(a, b, NULL);
|
|
||||||
--
|
|
||||||
2.27.0
|
|
||||||
|
|
||||||
@ -1,40 +0,0 @@
|
|||||||
From 4dd2cdf016e40c88b57480d9c296d6c7c2cb6600 Mon Sep 17 00:00:00 2001
|
|
||||||
From: tangzhongrui <tangzhongrui@cmss.chinamobile.com>
|
|
||||||
Date: Thu, 1 Dec 2022 20:24:53 +0800
|
|
||||||
Subject: [PATCH 06/17] Fix several typos in documentation
|
|
||||||
|
|
||||||
Signed-off-by: tangzhongrui tangzhongrui@cmss.chinamobile.com
|
|
||||||
---
|
|
||||||
docs/can.txt | 2 +-
|
|
||||||
hw/virtio/virtio-mem.c | 2 +-
|
|
||||||
2 files changed, 2 insertions(+), 2 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/docs/can.txt b/docs/can.txt
|
|
||||||
index 0d310237df..873c95a35d 100644
|
|
||||||
--- a/docs/can.txt
|
|
||||||
+++ b/docs/can.txt
|
|
||||||
@@ -166,7 +166,7 @@ and with bitrate switch
|
|
||||||
|
|
||||||
cangen can0 -b
|
|
||||||
|
|
||||||
-The test can be run viceversa, generate messages in the guest system and capture them
|
|
||||||
+The test can be run vice-versa, generate messages in the guest system and capture them
|
|
||||||
in the host one and much more combinations.
|
|
||||||
|
|
||||||
Links to other resources
|
|
||||||
diff --git a/hw/virtio/virtio-mem.c b/hw/virtio/virtio-mem.c
|
|
||||||
index 341c3fa2c1..becac0d93b 100644
|
|
||||||
--- a/hw/virtio/virtio-mem.c
|
|
||||||
+++ b/hw/virtio/virtio-mem.c
|
|
||||||
@@ -877,7 +877,7 @@ static int virtio_mem_mig_sanity_checks_post_load(void *opaque, int version_id)
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
- * Note: Preparation for resizeable memory regions. The maximum size
|
|
||||||
+ * Note: Preparation for resizable memory regions. The maximum size
|
|
||||||
* of the memory region must not change during migration.
|
|
||||||
*/
|
|
||||||
if (tmp->region_size != new_region_size) {
|
|
||||||
--
|
|
||||||
2.27.0
|
|
||||||
|
|
||||||
@ -1,43 +0,0 @@
|
|||||||
From 08d0374d80ef321a421d4d9716c05006b469c78f Mon Sep 17 00:00:00 2001
|
|
||||||
From: lixianglai <lixianglai@loongson.cn>
|
|
||||||
Date: Wed, 24 May 2023 23:06:51 -0400
|
|
||||||
Subject: [PATCH] Fix smp.cores value and Fix divide 0 error
|
|
||||||
|
|
||||||
The smp.cores should use the default value passed from
|
|
||||||
qemu start command, and the argument is cores_per_socket.
|
|
||||||
|
|
||||||
The variable nb_numa_nodes may be 0, and a division by 0
|
|
||||||
error will occur later, and special treatment is done for
|
|
||||||
nb_numa_nodes here.
|
|
||||||
|
|
||||||
Signed-off-by: lixianglai <lixianglai@loongson.cn>
|
|
||||||
---
|
|
||||||
hw/loongarch/larch_3a.c | 5 ++++-
|
|
||||||
1 file changed, 4 insertions(+), 1 deletion(-)
|
|
||||||
|
|
||||||
diff --git a/hw/loongarch/larch_3a.c b/hw/loongarch/larch_3a.c
|
|
||||||
index fe786008ac..cef1a6f3d2 100644
|
|
||||||
--- a/hw/loongarch/larch_3a.c
|
|
||||||
+++ b/hw/loongarch/larch_3a.c
|
|
||||||
@@ -1221,7 +1221,6 @@ static void loongarch_build_smbios(LoongarchMachineState *lsms)
|
|
||||||
uint8_t *smbios_tables, *smbios_anchor;
|
|
||||||
size_t smbios_tables_len, smbios_anchor_len;
|
|
||||||
const char *product = "QEMU Virtual Machine";
|
|
||||||
- ms->smp.cores = 4;
|
|
||||||
|
|
||||||
if (!lsms->fw_cfg) {
|
|
||||||
return;
|
|
||||||
@@ -2005,6 +2004,10 @@ static int64_t ls3a_get_default_cpu_node_id(const MachineState *ms, int idx)
|
|
||||||
{
|
|
||||||
int nb_numa_nodes = ms->numa_state->num_nodes;
|
|
||||||
int smp_cores = ms->smp.cores;
|
|
||||||
+
|
|
||||||
+ if (nb_numa_nodes == 0) {
|
|
||||||
+ nb_numa_nodes = 1;
|
|
||||||
+ }
|
|
||||||
return idx / smp_cores % nb_numa_nodes;
|
|
||||||
}
|
|
||||||
|
|
||||||
--
|
|
||||||
2.41.0.windows.1
|
|
||||||
|
|
||||||
@ -1,83 +0,0 @@
|
|||||||
From 6de250962994520ba8daca709cd4b3b54d5e3afb Mon Sep 17 00:00:00 2001
|
|
||||||
From: Luo Yifan <luoyifan_yewu@cmss.chinamobile.com>
|
|
||||||
Date: Fri, 1 Dec 2023 10:47:48 +0800
|
|
||||||
Subject: [PATCH] Fixed a QEMU hang when guest poweroff in COLO mode
|
|
||||||
|
|
||||||
cherry picked from commit 795969ab1fe6d5a0f524be92e2e1ecd13f1873eb
|
|
||||||
|
|
||||||
When the PVM guest poweroff, the COLO thread may wait a semaphore
|
|
||||||
in colo_process_checkpoint().So, we should wake up the COLO thread
|
|
||||||
before migration shutdown.
|
|
||||||
|
|
||||||
Signed-off-by: Lei Rao <lei.rao@intel.com>
|
|
||||||
Reviewed-by: Zhang Chen <chen.zhang@intel.com>
|
|
||||||
Reviewed-by: Juan Quintela <quintela@redhat.com>
|
|
||||||
Signed-off-by: Juan Quintela <quintela@redhat.com>
|
|
||||||
Signed-off-by: Luo Yifan <luoyifan_yewu@cmss.chinamobile.com>
|
|
||||||
---
|
|
||||||
include/migration/colo.h | 1 +
|
|
||||||
migration/colo.c | 20 ++++++++++++++++++++
|
|
||||||
migration/migration.c | 6 ++++++
|
|
||||||
3 files changed, 27 insertions(+)
|
|
||||||
|
|
||||||
diff --git a/include/migration/colo.h b/include/migration/colo.h
|
|
||||||
index 768e1f04c3..5fbe1a6d5d 100644
|
|
||||||
--- a/include/migration/colo.h
|
|
||||||
+++ b/include/migration/colo.h
|
|
||||||
@@ -37,4 +37,5 @@ COLOMode get_colo_mode(void);
|
|
||||||
void colo_do_failover(void);
|
|
||||||
|
|
||||||
void colo_checkpoint_notify(void *opaque);
|
|
||||||
+void colo_shutdown(void);
|
|
||||||
#endif
|
|
||||||
diff --git a/migration/colo.c b/migration/colo.c
|
|
||||||
index 2415325262..0d3d98f707 100644
|
|
||||||
--- a/migration/colo.c
|
|
||||||
+++ b/migration/colo.c
|
|
||||||
@@ -820,6 +820,26 @@ static void colo_wait_handle_message(MigrationIncomingState *mis,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
+void colo_shutdown(void)
|
|
||||||
+{
|
|
||||||
+ MigrationIncomingState *mis = NULL;
|
|
||||||
+ MigrationState *s = NULL;
|
|
||||||
+
|
|
||||||
+ switch (get_colo_mode()) {
|
|
||||||
+ case COLO_MODE_PRIMARY:
|
|
||||||
+ s = migrate_get_current();
|
|
||||||
+ qemu_event_set(&s->colo_checkpoint_event);
|
|
||||||
+ qemu_sem_post(&s->colo_exit_sem);
|
|
||||||
+ break;
|
|
||||||
+ case COLO_MODE_SECONDARY:
|
|
||||||
+ mis = migration_incoming_get_current();
|
|
||||||
+ qemu_sem_post(&mis->colo_incoming_sem);
|
|
||||||
+ break;
|
|
||||||
+ default:
|
|
||||||
+ break;
|
|
||||||
+ }
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
void *colo_process_incoming_thread(void *opaque)
|
|
||||||
{
|
|
||||||
MigrationIncomingState *mis = opaque;
|
|
||||||
diff --git a/migration/migration.c b/migration/migration.c
|
|
||||||
index 2ec116f901..cceaacc7f7 100644
|
|
||||||
--- a/migration/migration.c
|
|
||||||
+++ b/migration/migration.c
|
|
||||||
@@ -226,6 +226,12 @@ void migration_cancel(const Error *error)
|
|
||||||
|
|
||||||
void migration_shutdown(void)
|
|
||||||
{
|
|
||||||
+ /*
|
|
||||||
+ * When the QEMU main thread exit, the COLO thread
|
|
||||||
+ * may wait a semaphore. So, we should wakeup the
|
|
||||||
+ * COLO thread before migration shutdown.
|
|
||||||
+ */
|
|
||||||
+ colo_shutdown();
|
|
||||||
/*
|
|
||||||
* Cancel the current migration - that will (eventually)
|
|
||||||
* stop the migration using this structure
|
|
||||||
--
|
|
||||||
2.27.0
|
|
||||||
|
|
||||||
@ -1,28 +0,0 @@
|
|||||||
From 039e70e84d966ee28267f3fe76c8558ef65619f9 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Yan Wang <wangyan122@huawei.com>
|
|
||||||
Date: Sat, 12 Feb 2022 14:31:00 +0800
|
|
||||||
Subject: [PATCH] IPv6: add support for IPv6 protocol
|
|
||||||
|
|
||||||
Add support for IPv6 protocol.
|
|
||||||
|
|
||||||
Signed-off-by: Yan Wang <wangyan122@huawei.com>
|
|
||||||
---
|
|
||||||
roms/ipxe/src/config/general.h | 2 +-
|
|
||||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
|
||||||
|
|
||||||
diff --git a/roms/ipxe/src/config/general.h b/roms/ipxe/src/config/general.h
|
|
||||||
index 3c14a2c..e7ce2b9 100644
|
|
||||||
--- a/roms/ipxe/src/config/general.h
|
|
||||||
+++ b/roms/ipxe/src/config/general.h
|
|
||||||
@@ -35,7 +35,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define NET_PROTO_IPV4 /* IPv4 protocol */
|
|
||||||
-#undef NET_PROTO_IPV6 /* IPv6 protocol */
|
|
||||||
+#define NET_PROTO_IPV6 /* IPv6 protocol */
|
|
||||||
#undef NET_PROTO_FCOE /* Fibre Channel over Ethernet protocol */
|
|
||||||
#define NET_PROTO_STP /* Spanning Tree protocol */
|
|
||||||
#define NET_PROTO_LACP /* Link Aggregation control protocol */
|
|
||||||
--
|
|
||||||
1.9.1
|
|
||||||
|
|
||||||
@ -1,113 +0,0 @@
|
|||||||
From 49cb3c9f3cc3a567ce2e6159bf27328c64b6601d Mon Sep 17 00:00:00 2001
|
|
||||||
From: Paolo Bonzini <pbonzini@redhat.com>
|
|
||||||
Date: Wed, 23 Mar 2022 12:33:25 +0100
|
|
||||||
Subject: [PATCH 10/10] KVM: x86: workaround invalid CPUID[0xD,9] info on some
|
|
||||||
AMD processors
|
|
||||||
MIME-Version: 1.0
|
|
||||||
Content-Type: text/plain; charset=UTF-8
|
|
||||||
Content-Transfer-Encoding: 8bit
|
|
||||||
|
|
||||||
from mainline-v7.0.0-rc2
|
|
||||||
commit 58f7db26f21c690cf9a669c314cfd7371506084a
|
|
||||||
category: feature
|
|
||||||
feature: SPR AMX support for Qemu
|
|
||||||
bugzilla: https://gitee.com/openeuler/intel-qemu/issues/I5VHOB
|
|
||||||
|
|
||||||
Intel-SIG: commit 58f7db26f21c ("KVM: x86: workaround invalid CPUID[0xD,9] info
|
|
||||||
on some AMD processors")
|
|
||||||
|
|
||||||
----------------------------------------------------------------
|
|
||||||
|
|
||||||
KVM: x86: workaround invalid CPUID[0xD,9] info on some AMD processors
|
|
||||||
|
|
||||||
Some AMD processors expose the PKRU extended save state even if they do not have
|
|
||||||
the related PKU feature in CPUID. Worse, when they do they report a size of
|
|
||||||
64, whereas the expected size of the PKRU extended save state is 8, therefore
|
|
||||||
the esa->size == eax assertion does not hold.
|
|
||||||
|
|
||||||
The state is already ignored by KVM_GET_SUPPORTED_CPUID because it
|
|
||||||
was not enabled in the host XCR0. However, QEMU kvm_cpu_xsave_init()
|
|
||||||
runs before QEMU invokes arch_prctl() to enable dynamically-enabled
|
|
||||||
save states such as XTILEDATA, and KVM_GET_SUPPORTED_CPUID hides save
|
|
||||||
states that have yet to be enabled. Therefore, kvm_cpu_xsave_init()
|
|
||||||
needs to consult the host CPUID instead of KVM_GET_SUPPORTED_CPUID,
|
|
||||||
and dies with an assertion failure.
|
|
||||||
|
|
||||||
When setting up the ExtSaveArea array to match the host, ignore features that
|
|
||||||
KVM does not report as supported. This will cause QEMU to skip the incorrect
|
|
||||||
CPUID leaf instead of tripping the assertion.
|
|
||||||
|
|
||||||
Closes: https://gitlab.com/qemu-project/qemu/-/issues/916
|
|
||||||
Reported-by: Daniel P. Berrangé <berrange@redhat.com>
|
|
||||||
Analyzed-by: Yang Zhong <yang.zhong@intel.com>
|
|
||||||
Reported-by: Peter Krempa <pkrempa@redhat.com>
|
|
||||||
Tested-by: Daniel P. Berrangé <berrange@redhat.com>
|
|
||||||
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
||||||
Signed-off-by: Jason Zeng <jason.zeng@intel.com>
|
|
||||||
---
|
|
||||||
target/i386/cpu.c | 4 ++--
|
|
||||||
target/i386/cpu.h | 2 ++
|
|
||||||
target/i386/kvm/kvm-cpu.c | 19 ++++++++++++-------
|
|
||||||
3 files changed, 16 insertions(+), 9 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/target/i386/cpu.c b/target/i386/cpu.c
|
|
||||||
index 1bc03d3eef..551b47ab1e 100644
|
|
||||||
--- a/target/i386/cpu.c
|
|
||||||
+++ b/target/i386/cpu.c
|
|
||||||
@@ -4973,8 +4973,8 @@ CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp)
|
|
||||||
return cpu_list;
|
|
||||||
}
|
|
||||||
|
|
||||||
-static uint64_t x86_cpu_get_supported_feature_word(FeatureWord w,
|
|
||||||
- bool migratable_only)
|
|
||||||
+uint64_t x86_cpu_get_supported_feature_word(FeatureWord w,
|
|
||||||
+ bool migratable_only)
|
|
||||||
{
|
|
||||||
FeatureWordInfo *wi = &feature_word_info[w];
|
|
||||||
uint64_t r = 0;
|
|
||||||
diff --git a/target/i386/cpu.h b/target/i386/cpu.h
|
|
||||||
index eaa99c302f..290f1beaea 100644
|
|
||||||
--- a/target/i386/cpu.h
|
|
||||||
+++ b/target/i386/cpu.h
|
|
||||||
@@ -605,6 +605,8 @@ typedef enum FeatureWord {
|
|
||||||
} FeatureWord;
|
|
||||||
|
|
||||||
typedef uint64_t FeatureWordArray[FEATURE_WORDS];
|
|
||||||
+uint64_t x86_cpu_get_supported_feature_word(FeatureWord w,
|
|
||||||
+ bool migratable_only);
|
|
||||||
|
|
||||||
/* cpuid_features bits */
|
|
||||||
#define CPUID_FP87 (1U << 0)
|
|
||||||
diff --git a/target/i386/kvm/kvm-cpu.c b/target/i386/kvm/kvm-cpu.c
|
|
||||||
index a35a1bf9fe..5eb955ce9a 100644
|
|
||||||
--- a/target/i386/kvm/kvm-cpu.c
|
|
||||||
+++ b/target/i386/kvm/kvm-cpu.c
|
|
||||||
@@ -99,13 +99,18 @@ static void kvm_cpu_xsave_init(void)
|
|
||||||
for (i = XSTATE_SSE_BIT + 1; i < XSAVE_STATE_AREA_COUNT; i++) {
|
|
||||||
ExtSaveArea *esa = &x86_ext_save_areas[i];
|
|
||||||
|
|
||||||
- if (esa->size) {
|
|
||||||
- host_cpuid(0xd, i, &eax, &ebx, &ecx, &edx);
|
|
||||||
- if (eax != 0) {
|
|
||||||
- assert(esa->size == eax);
|
|
||||||
- esa->offset = ebx;
|
|
||||||
- esa->ecx = ecx;
|
|
||||||
- }
|
|
||||||
+ if (!esa->size) {
|
|
||||||
+ continue;
|
|
||||||
+ }
|
|
||||||
+ if ((x86_cpu_get_supported_feature_word(esa->feature, false) & esa->bits)
|
|
||||||
+ != esa->bits) {
|
|
||||||
+ continue;
|
|
||||||
+ }
|
|
||||||
+ host_cpuid(0xd, i, &eax, &ebx, &ecx, &edx);
|
|
||||||
+ if (eax != 0) {
|
|
||||||
+ assert(esa->size == eax);
|
|
||||||
+ esa->offset = ebx;
|
|
||||||
+ esa->ecx = ecx;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
--
|
|
||||||
2.27.0
|
|
||||||
|
|
||||||
@ -1,110 +0,0 @@
|
|||||||
From a7d32227e6a7b3eff114135f68f980ac686f6b80 Mon Sep 17 00:00:00 2001
|
|
||||||
From: zhujun2 <zhujun2_yewu@cmss.chinamobile.com>
|
|
||||||
Date: Sun, 30 Jul 2023 23:14:18 -0700
|
|
||||||
Subject: [PATCH] QGA VSS: Add wrapper to send log to debugger and stderr
|
|
||||||
mainline inclusion commit 925d05d38a2bc76b5a49359370650a820bc891da category:
|
|
||||||
bugfix
|
|
||||||
|
|
||||||
Reviewed-by: Thomas Huth <thuth@redhat.com>
|
|
||||||
Signed-off-by: Konstantin Kostiuk <kkostiuk@redhat.com>
|
|
||||||
Signed-off-by: zhujun2 <zhujun2_yewu@cmss.chinamobile.com>
|
|
||||||
---
|
|
||||||
qga/vss-win32/meson.build | 2 +-
|
|
||||||
qga/vss-win32/vss-debug.cpp | 39 +++++++++++++++++++++++++++++++++++++
|
|
||||||
qga/vss-win32/vss-debug.h | 25 ++++++++++++++++++++++++
|
|
||||||
3 files changed, 65 insertions(+), 1 deletion(-)
|
|
||||||
create mode 100644 qga/vss-win32/vss-debug.cpp
|
|
||||||
create mode 100644 qga/vss-win32/vss-debug.h
|
|
||||||
|
|
||||||
diff --git a/qga/vss-win32/meson.build b/qga/vss-win32/meson.build
|
|
||||||
index 90825edef3..290796556c 100644
|
|
||||||
--- a/qga/vss-win32/meson.build
|
|
||||||
+++ b/qga/vss-win32/meson.build
|
|
||||||
@@ -3,7 +3,7 @@ if add_languages('cpp', required: false)
|
|
||||||
link_args = cc.get_supported_link_arguments(['-fstack-protector-all', '-fstack-protector-strong',
|
|
||||||
'-Wl,--add-stdcall-alias', '-Wl,--enable-stdcall-fixup'])
|
|
||||||
|
|
||||||
- qga_vss = shared_module('qga-vss', ['requester.cpp', 'provider.cpp', 'install.cpp'],
|
|
||||||
+ qga_vss = shared_module('qga-vss', ['requester.cpp', 'provider.cpp', 'install.cpp', 'vss-debug.cpp'],
|
|
||||||
name_prefix: '',
|
|
||||||
cpp_args: ['-Wno-unknown-pragmas', '-Wno-delete-non-virtual-dtor', '-Wno-non-virtual-dtor'],
|
|
||||||
link_args: link_args,
|
|
||||||
diff --git a/qga/vss-win32/vss-debug.cpp b/qga/vss-win32/vss-debug.cpp
|
|
||||||
new file mode 100644
|
|
||||||
index 0000000000..820b1c6667
|
|
||||||
--- /dev/null
|
|
||||||
+++ b/qga/vss-win32/vss-debug.cpp
|
|
||||||
@@ -0,0 +1,39 @@
|
|
||||||
+/*
|
|
||||||
+ * QEMU Guest Agent VSS debug declarations
|
|
||||||
+ *
|
|
||||||
+ * Copyright (C) 2023 Red Hat Inc
|
|
||||||
+ *
|
|
||||||
+ * Authors:
|
|
||||||
+ * Konstantin Kostiuk <kkostiuk@redhat.com>
|
|
||||||
+ *
|
|
||||||
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
|
|
||||||
+ * See the COPYING file in the top-level directory.
|
|
||||||
+ */
|
|
||||||
+
|
|
||||||
+#include "qemu/osdep.h"
|
|
||||||
+#include "vss-debug.h"
|
|
||||||
+#include "vss-common.h"
|
|
||||||
+
|
|
||||||
+void qga_debug_internal(const char *funcname, const char *fmt, ...)
|
|
||||||
+{
|
|
||||||
+ char user_string[512] = {0};
|
|
||||||
+ char full_string[640] = {0};
|
|
||||||
+
|
|
||||||
+ va_list args;
|
|
||||||
+ va_start(args, fmt);
|
|
||||||
+ if (vsnprintf(user_string, _countof(user_string), fmt, args) <= 0) {
|
|
||||||
+ va_end(args);
|
|
||||||
+ return;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ va_end(args);
|
|
||||||
+
|
|
||||||
+ if (snprintf(full_string, _countof(full_string),
|
|
||||||
+ QGA_PROVIDER_NAME "[%lu]: %s %s\n",
|
|
||||||
+ GetCurrentThreadId(), funcname, user_string) <= 0) {
|
|
||||||
+ return;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ OutputDebugString(full_string);
|
|
||||||
+ fputs(full_string, stderr);
|
|
||||||
+}
|
|
||||||
diff --git a/qga/vss-win32/vss-debug.h b/qga/vss-win32/vss-debug.h
|
|
||||||
new file mode 100644
|
|
||||||
index 0000000000..7800457392
|
|
||||||
--- /dev/null
|
|
||||||
+++ b/qga/vss-win32/vss-debug.h
|
|
||||||
@@ -0,0 +1,25 @@
|
|
||||||
+/*
|
|
||||||
+ * QEMU Guest Agent VSS debug declarations
|
|
||||||
+ *
|
|
||||||
+ * Copyright (C) 2023 Red Hat Inc
|
|
||||||
+ *
|
|
||||||
+ * Authors:
|
|
||||||
+ * Konstantin Kostiuk <kkostiuk@redhat.com>
|
|
||||||
+ *
|
|
||||||
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
|
|
||||||
+ * See the COPYING file in the top-level directory.
|
|
||||||
+ */
|
|
||||||
+
|
|
||||||
+#include "qemu/osdep.h"
|
|
||||||
+#include <vss-handles.h>
|
|
||||||
+
|
|
||||||
+#ifndef VSS_DEBUG_H
|
|
||||||
+#define VSS_DEBUG_H
|
|
||||||
+
|
|
||||||
+void qga_debug_internal(const char *funcname, const char *fmt, ...) G_GNUC_PRINTF(2, 3);
|
|
||||||
+
|
|
||||||
+#define qga_debug(fmt, ...) qga_debug_internal(__func__, fmt, ## __VA_ARGS__)
|
|
||||||
+#define qga_debug_begin qga_debug("begin")
|
|
||||||
+#define qga_debug_end qga_debug("end")
|
|
||||||
+
|
|
||||||
+#endif
|
|
||||||
--
|
|
||||||
2.41.0.windows.1
|
|
||||||
|
|
||||||
@ -1,25 +0,0 @@
|
|||||||
From 7b859a86cbdde8bf17619c43a6d4ae687a20f003 Mon Sep 17 00:00:00 2001
|
|
||||||
From: dinglimin <dinglimin@cmss.chinamobile.com>
|
|
||||||
Date: Wed, 29 Jun 2022 16:26:17 +0800
|
|
||||||
Subject: [PATCH] Remove the unused local variable "records".
|
|
||||||
|
|
||||||
Signed-off-by: dinglimin <dinglimin@cmss.chinamobile.com>
|
|
||||||
---
|
|
||||||
tests/migration/guestperf/engine.py | 1 -
|
|
||||||
1 file changed, 1 deletion(-)
|
|
||||||
|
|
||||||
diff --git a/tests/migration/guestperf/engine.py b/tests/migration/guestperf/engine.py
|
|
||||||
index 87a6ab2009..59fca2c70b 100644
|
|
||||||
--- a/tests/migration/guestperf/engine.py
|
|
||||||
+++ b/tests/migration/guestperf/engine.py
|
|
||||||
@@ -65,7 +65,6 @@ def _vcpu_timing(self, pid, tid_list):
|
|
||||||
return records
|
|
||||||
|
|
||||||
def _cpu_timing(self, pid):
|
|
||||||
- records = []
|
|
||||||
now = time.time()
|
|
||||||
|
|
||||||
jiffies_per_sec = os.sysconf(os.sysconf_names['SC_CLK_TCK'])
|
|
||||||
--
|
|
||||||
2.27.0
|
|
||||||
|
|
||||||
@ -1,25 +0,0 @@
|
|||||||
From e7ef56975af8553690afb16f32fe74d62762b853 Mon Sep 17 00:00:00 2001
|
|
||||||
From: dinglimin <dinglimin@cmss.chinamobile.com>
|
|
||||||
Date: Wed, 29 Jun 2022 14:02:59 +0800
|
|
||||||
Subject: [PATCH] Remove this redundant return.
|
|
||||||
|
|
||||||
Signed-off-by: dinglimin <dinglimin@cmss.chinamobile.com>
|
|
||||||
---
|
|
||||||
scripts/vmstate-static-checker.py | 1 -
|
|
||||||
1 file changed, 1 deletion(-)
|
|
||||||
|
|
||||||
diff --git a/scripts/vmstate-static-checker.py b/scripts/vmstate-static-checker.py
|
|
||||||
index 539ead62b4..6838bf7e7c 100755
|
|
||||||
--- a/scripts/vmstate-static-checker.py
|
|
||||||
+++ b/scripts/vmstate-static-checker.py
|
|
||||||
@@ -367,7 +367,6 @@ def check_machine_type(s, d):
|
|
||||||
if s["Name"] != d["Name"]:
|
|
||||||
print("Warning: checking incompatible machine types:", end=' ')
|
|
||||||
print("\"" + s["Name"] + "\", \"" + d["Name"] + "\"")
|
|
||||||
- return
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
|
||||||
--
|
|
||||||
2.27.0
|
|
||||||
|
|
||||||
@ -1,49 +0,0 @@
|
|||||||
From 7474971c6fd6c6f77e66ded125e5f2521c7e12a2 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Mingwang Li <limingwang@huawei.com>
|
|
||||||
Date: Wed, 9 Feb 2022 17:35:52 +0800
|
|
||||||
Subject: [PATCH 2/3] Revert "cpu: add Cortex-A72 processor kvm target support"
|
|
||||||
|
|
||||||
This reverts commit f0da7fa5230b5f771570b2c12288e4a56a20dd97.
|
|
||||||
|
|
||||||
Signed-off-by: Mingwang Li <limingwang@huawei.com>
|
|
||||||
---
|
|
||||||
target/arm/cpu64.c | 1 -
|
|
||||||
target/arm/kvm-consts.h | 3 ---
|
|
||||||
2 files changed, 4 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c
|
|
||||||
index bd8e5b5676..26419fe994 100644
|
|
||||||
--- a/target/arm/cpu64.c
|
|
||||||
+++ b/target/arm/cpu64.c
|
|
||||||
@@ -202,7 +202,6 @@ static void aarch64_a72_initfn(Object *obj)
|
|
||||||
ARMCPU *cpu = ARM_CPU(obj);
|
|
||||||
|
|
||||||
cpu->dtb_compatible = "arm,cortex-a72";
|
|
||||||
- cpu->kvm_target = QEMU_KVM_ARM_TARGET_GENERIC_V8;
|
|
||||||
set_feature(&cpu->env, ARM_FEATURE_V8);
|
|
||||||
set_feature(&cpu->env, ARM_FEATURE_NEON);
|
|
||||||
set_feature(&cpu->env, ARM_FEATURE_GENERIC_TIMER);
|
|
||||||
diff --git a/target/arm/kvm-consts.h b/target/arm/kvm-consts.h
|
|
||||||
index 5f1311ade7..580f1c1fee 100644
|
|
||||||
--- a/target/arm/kvm-consts.h
|
|
||||||
+++ b/target/arm/kvm-consts.h
|
|
||||||
@@ -130,8 +130,6 @@ MISMATCH_CHECK(QEMU_PSCI_RET_DISABLED, PSCI_RET_DISABLED);
|
|
||||||
#define QEMU_KVM_ARM_TARGET_CORTEX_A57 2
|
|
||||||
#define QEMU_KVM_ARM_TARGET_XGENE_POTENZA 3
|
|
||||||
#define QEMU_KVM_ARM_TARGET_CORTEX_A53 4
|
|
||||||
-/* Generic ARM v8 target */
|
|
||||||
-#define QEMU_KVM_ARM_TARGET_GENERIC_V8 5
|
|
||||||
|
|
||||||
/* There's no kernel define for this: sentinel value which
|
|
||||||
* matches no KVM target value for either 64 or 32 bit
|
|
||||||
@@ -143,7 +141,6 @@ MISMATCH_CHECK(QEMU_KVM_ARM_TARGET_FOUNDATION_V8, KVM_ARM_TARGET_FOUNDATION_V8);
|
|
||||||
MISMATCH_CHECK(QEMU_KVM_ARM_TARGET_CORTEX_A57, KVM_ARM_TARGET_CORTEX_A57);
|
|
||||||
MISMATCH_CHECK(QEMU_KVM_ARM_TARGET_XGENE_POTENZA, KVM_ARM_TARGET_XGENE_POTENZA);
|
|
||||||
MISMATCH_CHECK(QEMU_KVM_ARM_TARGET_CORTEX_A53, KVM_ARM_TARGET_CORTEX_A53);
|
|
||||||
-MISMATCH_CHECK(QEMU_KVM_ARM_TARGET_GENERIC_V8, KVM_ARM_TARGET_GENERIC_V8);
|
|
||||||
|
|
||||||
#define CP_REG_ARM64 0x6000000000000000ULL
|
|
||||||
#define CP_REG_ARM_COPROC_MASK 0x000000000FFF0000
|
|
||||||
--
|
|
||||||
2.27.0
|
|
||||||
|
|
||||||
@ -1,67 +0,0 @@
|
|||||||
From cae52ca5b1dd4a295eaabc9649481f3d6a684f06 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Mingwang Li <limingwang@huawei.com>
|
|
||||||
Date: Wed, 9 Feb 2022 17:33:26 +0800
|
|
||||||
Subject: [PATCH 1/3] Revert "cpu: parse +/- feature to avoid failure"
|
|
||||||
|
|
||||||
This reverts commit ef83cde8dd2c9b404527354489b14d2bd238733d.
|
|
||||||
|
|
||||||
Signed-off-by: Mingwang Li <limingwang@huawei.com>
|
|
||||||
---
|
|
||||||
target/arm/cpu64.c | 37 -------------------------------------
|
|
||||||
1 file changed, 37 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c
|
|
||||||
index 08d886de7b..bd8e5b5676 100644
|
|
||||||
--- a/target/arm/cpu64.c
|
|
||||||
+++ b/target/arm/cpu64.c
|
|
||||||
@@ -983,47 +983,10 @@ static gchar *aarch64_gdb_arch_name(CPUState *cs)
|
|
||||||
return g_strdup("aarch64");
|
|
||||||
}
|
|
||||||
|
|
||||||
-/* Parse "+feature,-feature,feature=foo" CPU feature string
|
|
||||||
- */
|
|
||||||
-static void arm_cpu_parse_featurestr(const char *typename, char *features,
|
|
||||||
- Error **errp )
|
|
||||||
-{
|
|
||||||
- char *featurestr;
|
|
||||||
- char *val;
|
|
||||||
- static bool cpu_globals_initialized;
|
|
||||||
-
|
|
||||||
- if (cpu_globals_initialized) {
|
|
||||||
- return;
|
|
||||||
- }
|
|
||||||
- cpu_globals_initialized = true;
|
|
||||||
-
|
|
||||||
- featurestr = features ? strtok(features, ",") : NULL;
|
|
||||||
- while (featurestr) {
|
|
||||||
- val = strchr(featurestr, '=');
|
|
||||||
- if (val) {
|
|
||||||
- GlobalProperty *prop = g_new0(typeof(*prop), 1);
|
|
||||||
- *val = 0;
|
|
||||||
- val++;
|
|
||||||
- prop->driver = typename;
|
|
||||||
- prop->property = g_strdup(featurestr);
|
|
||||||
- prop->value = g_strdup(val);
|
|
||||||
- qdev_prop_register_global(prop);
|
|
||||||
- } else if (featurestr[0] == '+' || featurestr[0] == '-') {
|
|
||||||
- warn_report("Ignore %s feature\n", featurestr);
|
|
||||||
- } else {
|
|
||||||
- error_setg(errp, "Expected key=value format, found %s.",
|
|
||||||
- featurestr);
|
|
||||||
- return;
|
|
||||||
- }
|
|
||||||
- featurestr = strtok(NULL, ",");
|
|
||||||
- }
|
|
||||||
-}
|
|
||||||
-
|
|
||||||
static void aarch64_cpu_class_init(ObjectClass *oc, void *data)
|
|
||||||
{
|
|
||||||
CPUClass *cc = CPU_CLASS(oc);
|
|
||||||
|
|
||||||
- cc->parse_features = arm_cpu_parse_featurestr;
|
|
||||||
cc->gdb_read_register = aarch64_cpu_gdb_read_register;
|
|
||||||
cc->gdb_write_register = aarch64_cpu_gdb_write_register;
|
|
||||||
cc->gdb_num_core_regs = 34;
|
|
||||||
--
|
|
||||||
2.27.0
|
|
||||||
|
|
||||||
@ -1,28 +0,0 @@
|
|||||||
From c57d05a6ba11075b6998b98a204017c44f81759f Mon Sep 17 00:00:00 2001
|
|
||||||
From: Kunkun Jiang <jiangkunkun@huawei.com>
|
|
||||||
Date: Fri, 18 Nov 2022 15:22:55 +0800
|
|
||||||
Subject: [PATCH 32/36] Revert "hw/arm/smmu-common: Allow domain invalidation
|
|
||||||
for NH_ALL/NSNH_ALL"
|
|
||||||
|
|
||||||
This reverts commit 876d18c962f0ead31d8458cd7ac19178be78455c.
|
|
||||||
|
|
||||||
Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com>
|
|
||||||
---
|
|
||||||
hw/arm/smmu-common.c | 1 -
|
|
||||||
1 file changed, 1 deletion(-)
|
|
||||||
|
|
||||||
diff --git a/hw/arm/smmu-common.c b/hw/arm/smmu-common.c
|
|
||||||
index f253a27e1a..730dd20db1 100644
|
|
||||||
--- a/hw/arm/smmu-common.c
|
|
||||||
+++ b/hw/arm/smmu-common.c
|
|
||||||
@@ -478,7 +478,6 @@ static void smmu_unmap_notifier_range(IOMMUNotifier *n)
|
|
||||||
event.entry.iova = n->start;
|
|
||||||
event.entry.perm = IOMMU_NONE;
|
|
||||||
event.entry.addr_mask = n->end - n->start;
|
|
||||||
- event.entry.granularity = IOMMU_INV_GRAN_DOMAIN;
|
|
||||||
|
|
||||||
memory_region_notify_iommu_one(n, &event);
|
|
||||||
}
|
|
||||||
--
|
|
||||||
2.27.0
|
|
||||||
|
|
||||||
@ -1,30 +0,0 @@
|
|||||||
From 6ce1e1161c833d59b659a9f50062439a24ce6995 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Kunkun Jiang <jiangkunkun@huawei.com>
|
|
||||||
Date: Fri, 18 Nov 2022 15:22:36 +0800
|
|
||||||
Subject: [PATCH 17/36] Revert "hw/arm/smmuv3: Advertise MSI_TRANSLATE
|
|
||||||
attribute"
|
|
||||||
|
|
||||||
This reverts commit 5a759ab19d508361053e388694546216705d173b.
|
|
||||||
|
|
||||||
Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com>
|
|
||||||
---
|
|
||||||
hw/arm/smmuv3.c | 3 ---
|
|
||||||
1 file changed, 3 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c
|
|
||||||
index 275f1db430..5a092506d3 100644
|
|
||||||
--- a/hw/arm/smmuv3.c
|
|
||||||
+++ b/hw/arm/smmuv3.c
|
|
||||||
@@ -1600,9 +1600,6 @@ static int smmuv3_get_attr(IOMMUMemoryRegion *iommu,
|
|
||||||
if (attr == IOMMU_ATTR_VFIO_NESTED) {
|
|
||||||
*(bool *) data = true;
|
|
||||||
return 0;
|
|
||||||
- } else if (attr == IOMMU_ATTR_MSI_TRANSLATE) {
|
|
||||||
- *(bool *) data = true;
|
|
||||||
- return 0;
|
|
||||||
}
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
--
|
|
||||||
2.27.0
|
|
||||||
|
|
||||||
@ -1,34 +0,0 @@
|
|||||||
From 27fb5c981f920fe6ee1345d35d5c3b6cff1b1ce6 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Kunkun Jiang <jiangkunkun@huawei.com>
|
|
||||||
Date: Fri, 18 Nov 2022 15:22:29 +0800
|
|
||||||
Subject: [PATCH 11/36] Revert "hw/arm/smmuv3: Allow MAP notifiers"
|
|
||||||
|
|
||||||
This reverts commit dc126664134989975ce9ab9e7d5d2c8916628bf6.
|
|
||||||
|
|
||||||
Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com>
|
|
||||||
---
|
|
||||||
hw/arm/smmuv3.c | 8 ++++++++
|
|
||||||
1 file changed, 8 insertions(+)
|
|
||||||
|
|
||||||
diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c
|
|
||||||
index 55e78db65d..ed932d3340 100644
|
|
||||||
--- a/hw/arm/smmuv3.c
|
|
||||||
+++ b/hw/arm/smmuv3.c
|
|
||||||
@@ -1632,6 +1632,14 @@ static int smmuv3_notify_flag_changed(IOMMUMemoryRegion *iommu,
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
+ if (new & IOMMU_NOTIFIER_MAP) {
|
|
||||||
+ error_setg(errp,
|
|
||||||
+ "device %02x.%02x.%x requires iommu MAP notifier which is "
|
|
||||||
+ "not currently supported", pci_bus_num(sdev->bus),
|
|
||||||
+ PCI_SLOT(sdev->devfn), PCI_FUNC(sdev->devfn));
|
|
||||||
+ return -EINVAL;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
if (old == IOMMU_NOTIFIER_NONE) {
|
|
||||||
trace_smmuv3_notify_flag_add(iommu->parent_obj.name);
|
|
||||||
QLIST_INSERT_HEAD(&s->devices_with_notifiers, sdev, next);
|
|
||||||
--
|
|
||||||
2.27.0
|
|
||||||
|
|
||||||
@ -1,29 +0,0 @@
|
|||||||
From 868d85814a59b1b710b3edf34a0916f6849b72c0 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Kunkun Jiang <jiangkunkun@huawei.com>
|
|
||||||
Date: Fri, 18 Nov 2022 15:22:33 +0800
|
|
||||||
Subject: [PATCH 15/36] Revert "hw/arm/smmuv3: Fill the IOTLBEntry arch_id on
|
|
||||||
NH_VA invalidation"
|
|
||||||
|
|
||||||
This reverts commit dcda615b3d9b1acffee3d31d57974cc9e4bd0dee.
|
|
||||||
|
|
||||||
Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com>
|
|
||||||
---
|
|
||||||
hw/arm/smmuv3.c | 2 --
|
|
||||||
1 file changed, 2 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c
|
|
||||||
index 3751fb3ea8..e09e54a9aa 100644
|
|
||||||
--- a/hw/arm/smmuv3.c
|
|
||||||
+++ b/hw/arm/smmuv3.c
|
|
||||||
@@ -837,8 +837,6 @@ static void smmuv3_notify_iova(IOMMUMemoryRegion *mr,
|
|
||||||
event.entry.iova = iova;
|
|
||||||
event.entry.addr_mask = num_pages * (1 << granule) - 1;
|
|
||||||
event.entry.perm = IOMMU_NONE;
|
|
||||||
- event.entry.flags = IOMMU_INV_FLAGS_ARCHID;
|
|
||||||
- event.entry.arch_id = asid;
|
|
||||||
|
|
||||||
memory_region_notify_iommu_one(n, &event);
|
|
||||||
}
|
|
||||||
--
|
|
||||||
2.27.0
|
|
||||||
|
|
||||||
@ -1,73 +0,0 @@
|
|||||||
From 62e581d9c6adfa3aebcefa8c5270aa6fc38ed541 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Kunkun Jiang <jiangkunkun@huawei.com>
|
|
||||||
Date: Fri, 18 Nov 2022 15:22:32 +0800
|
|
||||||
Subject: [PATCH 14/36] Revert "hw/arm/smmuv3: Fill the IOTLBEntry leaf field
|
|
||||||
on NH_VA invalidation"
|
|
||||||
|
|
||||||
This reverts commit c219274b7b6a472d7340a4f72a052ba33ed19659.
|
|
||||||
|
|
||||||
Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com>
|
|
||||||
---
|
|
||||||
hw/arm/smmuv3.c | 11 +++++------
|
|
||||||
1 file changed, 5 insertions(+), 6 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c
|
|
||||||
index cceb3794d4..3751fb3ea8 100644
|
|
||||||
--- a/hw/arm/smmuv3.c
|
|
||||||
+++ b/hw/arm/smmuv3.c
|
|
||||||
@@ -804,7 +804,7 @@ epilogue:
|
|
||||||
static void smmuv3_notify_iova(IOMMUMemoryRegion *mr,
|
|
||||||
IOMMUNotifier *n,
|
|
||||||
int asid, dma_addr_t iova,
|
|
||||||
- uint8_t tg, uint64_t num_pages, bool leaf)
|
|
||||||
+ uint8_t tg, uint64_t num_pages)
|
|
||||||
{
|
|
||||||
SMMUDevice *sdev = container_of(mr, SMMUDevice, iommu);
|
|
||||||
IOMMUTLBEvent event = {};
|
|
||||||
@@ -839,7 +839,6 @@ static void smmuv3_notify_iova(IOMMUMemoryRegion *mr,
|
|
||||||
event.entry.perm = IOMMU_NONE;
|
|
||||||
event.entry.flags = IOMMU_INV_FLAGS_ARCHID;
|
|
||||||
event.entry.arch_id = asid;
|
|
||||||
- event.entry.leaf = leaf;
|
|
||||||
|
|
||||||
memory_region_notify_iommu_one(n, &event);
|
|
||||||
}
|
|
||||||
@@ -871,7 +870,7 @@ static void smmuv3_notify_asid(IOMMUMemoryRegion *mr,
|
|
||||||
|
|
||||||
/* invalidate an asid/iova range tuple in all mr's */
|
|
||||||
static void smmuv3_inv_notifiers_iova(SMMUState *s, int asid, dma_addr_t iova,
|
|
||||||
- uint8_t tg, uint64_t num_pages, bool leaf)
|
|
||||||
+ uint8_t tg, uint64_t num_pages)
|
|
||||||
{
|
|
||||||
SMMUDevice *sdev;
|
|
||||||
|
|
||||||
@@ -883,7 +882,7 @@ static void smmuv3_inv_notifiers_iova(SMMUState *s, int asid, dma_addr_t iova,
|
|
||||||
tg, num_pages);
|
|
||||||
|
|
||||||
IOMMU_NOTIFIER_FOREACH(n, mr) {
|
|
||||||
- smmuv3_notify_iova(mr, n, asid, iova, tg, num_pages, leaf);
|
|
||||||
+ smmuv3_notify_iova(mr, n, asid, iova, tg, num_pages);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -908,7 +907,7 @@ static void smmuv3_s1_range_inval(SMMUState *s, Cmd *cmd)
|
|
||||||
|
|
||||||
if (!tg) {
|
|
||||||
trace_smmuv3_s1_range_inval(vmid, asid, addr, tg, 1, ttl, leaf);
|
|
||||||
- smmuv3_inv_notifiers_iova(s, asid, addr, tg, 1, leaf);
|
|
||||||
+ smmuv3_inv_notifiers_iova(s, asid, addr, tg, 1);
|
|
||||||
smmu_iotlb_inv_iova(s, asid, addr, tg, 1, ttl);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
@@ -926,7 +925,7 @@ static void smmuv3_s1_range_inval(SMMUState *s, Cmd *cmd)
|
|
||||||
|
|
||||||
num_pages = (mask + 1) >> granule;
|
|
||||||
trace_smmuv3_s1_range_inval(vmid, asid, addr, tg, num_pages, ttl, leaf);
|
|
||||||
- smmuv3_inv_notifiers_iova(s, asid, addr, tg, num_pages, leaf);
|
|
||||||
+ smmuv3_inv_notifiers_iova(s, asid, addr, tg, num_pages);
|
|
||||||
smmu_iotlb_inv_iova(s, asid, addr, tg, num_pages, ttl);
|
|
||||||
addr += mask + 1;
|
|
||||||
}
|
|
||||||
--
|
|
||||||
2.27.0
|
|
||||||
|
|
||||||
@ -1,104 +0,0 @@
|
|||||||
From 822386d862324be3c334faff790c1f6a64c5455a Mon Sep 17 00:00:00 2001
|
|
||||||
From: Kunkun Jiang <jiangkunkun@huawei.com>
|
|
||||||
Date: Fri, 18 Nov 2022 15:22:30 +0800
|
|
||||||
Subject: [PATCH 12/36] Revert "hw/arm/smmuv3: Implement fault injection"
|
|
||||||
|
|
||||||
This reverts commit d31c754470b4b651d0e19c66738fbcc8fc6abf3c.
|
|
||||||
|
|
||||||
Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com>
|
|
||||||
---
|
|
||||||
hw/arm/smmuv3.c | 71 -------------------------------------------------
|
|
||||||
1 file changed, 71 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c
|
|
||||||
index ed932d3340..514ce9d57d 100644
|
|
||||||
--- a/hw/arm/smmuv3.c
|
|
||||||
+++ b/hw/arm/smmuv3.c
|
|
||||||
@@ -1664,76 +1664,6 @@ static int smmuv3_get_attr(IOMMUMemoryRegion *iommu,
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
-struct iommu_fault;
|
|
||||||
-
|
|
||||||
-static inline int
|
|
||||||
-smmuv3_inject_faults(IOMMUMemoryRegion *iommu_mr, int count,
|
|
||||||
- struct iommu_fault *buf)
|
|
||||||
-{
|
|
||||||
-#ifdef __linux__
|
|
||||||
- SMMUDevice *sdev = container_of(iommu_mr, SMMUDevice, iommu);
|
|
||||||
- SMMUv3State *s3 = sdev->smmu;
|
|
||||||
- uint32_t sid = smmu_get_sid(sdev);
|
|
||||||
- int i;
|
|
||||||
-
|
|
||||||
- for (i = 0; i < count; i++) {
|
|
||||||
- SMMUEventInfo info = {};
|
|
||||||
- struct iommu_fault_unrecoverable *record;
|
|
||||||
-
|
|
||||||
- if (buf[i].type != IOMMU_FAULT_DMA_UNRECOV) {
|
|
||||||
- continue;
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
- info.sid = sid;
|
|
||||||
- record = &buf[i].event;
|
|
||||||
-
|
|
||||||
- switch (record->reason) {
|
|
||||||
- case IOMMU_FAULT_REASON_PASID_INVALID:
|
|
||||||
- info.type = SMMU_EVT_C_BAD_SUBSTREAMID;
|
|
||||||
- /* TODO further fill info.u.c_bad_substream */
|
|
||||||
- break;
|
|
||||||
- case IOMMU_FAULT_REASON_PASID_FETCH:
|
|
||||||
- info.type = SMMU_EVT_F_CD_FETCH;
|
|
||||||
- break;
|
|
||||||
- case IOMMU_FAULT_REASON_BAD_PASID_ENTRY:
|
|
||||||
- info.type = SMMU_EVT_C_BAD_CD;
|
|
||||||
- /* TODO further fill info.u.c_bad_cd */
|
|
||||||
- break;
|
|
||||||
- case IOMMU_FAULT_REASON_WALK_EABT:
|
|
||||||
- info.type = SMMU_EVT_F_WALK_EABT;
|
|
||||||
- info.u.f_walk_eabt.addr = record->addr;
|
|
||||||
- info.u.f_walk_eabt.addr2 = record->fetch_addr;
|
|
||||||
- break;
|
|
||||||
- case IOMMU_FAULT_REASON_PTE_FETCH:
|
|
||||||
- info.type = SMMU_EVT_F_TRANSLATION;
|
|
||||||
- info.u.f_translation.addr = record->addr;
|
|
||||||
- break;
|
|
||||||
- case IOMMU_FAULT_REASON_OOR_ADDRESS:
|
|
||||||
- info.type = SMMU_EVT_F_ADDR_SIZE;
|
|
||||||
- info.u.f_addr_size.addr = record->addr;
|
|
||||||
- break;
|
|
||||||
- case IOMMU_FAULT_REASON_ACCESS:
|
|
||||||
- info.type = SMMU_EVT_F_ACCESS;
|
|
||||||
- info.u.f_access.addr = record->addr;
|
|
||||||
- break;
|
|
||||||
- case IOMMU_FAULT_REASON_PERMISSION:
|
|
||||||
- info.type = SMMU_EVT_F_PERMISSION;
|
|
||||||
- info.u.f_permission.addr = record->addr;
|
|
||||||
- break;
|
|
||||||
- default:
|
|
||||||
- warn_report("%s Unexpected fault reason received from host: %d",
|
|
||||||
- __func__, record->reason);
|
|
||||||
- continue;
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
- smmuv3_record_event(s3, &info);
|
|
||||||
- }
|
|
||||||
- return 0;
|
|
||||||
-#else
|
|
||||||
- return -1;
|
|
||||||
-#endif
|
|
||||||
-}
|
|
||||||
-
|
|
||||||
static void smmuv3_iommu_memory_region_class_init(ObjectClass *klass,
|
|
||||||
void *data)
|
|
||||||
{
|
|
||||||
@@ -1742,7 +1672,6 @@ static void smmuv3_iommu_memory_region_class_init(ObjectClass *klass,
|
|
||||||
imrc->translate = smmuv3_translate;
|
|
||||||
imrc->notify_flag_changed = smmuv3_notify_flag_changed;
|
|
||||||
imrc->get_attr = smmuv3_get_attr;
|
|
||||||
- imrc->inject_faults = smmuv3_inject_faults;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const TypeInfo smmuv3_type_info = {
|
|
||||||
--
|
|
||||||
2.27.0
|
|
||||||
|
|
||||||
@ -1,98 +0,0 @@
|
|||||||
From 98ca0862f34c891a0e381bd382306398b88ac5bc Mon Sep 17 00:00:00 2001
|
|
||||||
From: Kunkun Jiang <jiangkunkun@huawei.com>
|
|
||||||
Date: Fri, 18 Nov 2022 15:22:56 +0800
|
|
||||||
Subject: [PATCH 33/36] Revert "hw/arm/smmuv3: Improve stage1 ASID
|
|
||||||
invalidation"
|
|
||||||
|
|
||||||
This reverts commit de53feaa37a267a21ed30a642e1e64c5fcfbc4a4.
|
|
||||||
|
|
||||||
Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com>
|
|
||||||
---
|
|
||||||
hw/arm/smmuv3.c | 44 ++------------------------------------------
|
|
||||||
hw/arm/trace-events | 1 -
|
|
||||||
2 files changed, 2 insertions(+), 43 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c
|
|
||||||
index f4de66827d..0e8fe646aa 100644
|
|
||||||
--- a/hw/arm/smmuv3.c
|
|
||||||
+++ b/hw/arm/smmuv3.c
|
|
||||||
@@ -840,31 +840,6 @@ static void smmuv3_notify_iova(IOMMUMemoryRegion *mr,
|
|
||||||
memory_region_notify_iommu_one(n, &event);
|
|
||||||
}
|
|
||||||
|
|
||||||
-/**
|
|
||||||
- * smmuv3_notify_asid - call the notifier @n for a given asid
|
|
||||||
- *
|
|
||||||
- * @mr: IOMMU mr region handle
|
|
||||||
- * @n: notifier to be called
|
|
||||||
- * @asid: address space ID or negative value if we don't care
|
|
||||||
- */
|
|
||||||
-static void smmuv3_notify_asid(IOMMUMemoryRegion *mr,
|
|
||||||
- IOMMUNotifier *n, int asid)
|
|
||||||
-{
|
|
||||||
- IOMMUTLBEvent event = {};
|
|
||||||
-
|
|
||||||
- event.type = IOMMU_NOTIFIER_UNMAP;
|
|
||||||
- event.entry.target_as = &address_space_memory;
|
|
||||||
- event.entry.perm = IOMMU_NONE;
|
|
||||||
- event.entry.granularity = IOMMU_INV_GRAN_PASID;
|
|
||||||
- event.entry.flags = IOMMU_INV_FLAGS_ARCHID;
|
|
||||||
- event.entry.arch_id = asid;
|
|
||||||
- event.entry.iova = n->start;
|
|
||||||
- event.entry.addr_mask = n->end - n->start;
|
|
||||||
-
|
|
||||||
- memory_region_notify_iommu_one(n, &event);
|
|
||||||
-}
|
|
||||||
-
|
|
||||||
-
|
|
||||||
/* invalidate an asid/iova range tuple in all mr's */
|
|
||||||
static void smmuv3_inv_notifiers_iova(SMMUState *s, int asid, dma_addr_t iova,
|
|
||||||
uint8_t tg, uint64_t num_pages)
|
|
||||||
@@ -942,22 +917,6 @@ smmuv3_invalidate_ste(gpointer key, gpointer value, gpointer user_data)
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
-static void smmuv3_s1_asid_inval(SMMUState *s, uint16_t asid)
|
|
||||||
-{
|
|
||||||
- SMMUDevice *sdev;
|
|
||||||
-
|
|
||||||
- trace_smmuv3_s1_asid_inval(asid);
|
|
||||||
- QLIST_FOREACH(sdev, &s->devices_with_notifiers, next) {
|
|
||||||
- IOMMUMemoryRegion *mr = &sdev->iommu;
|
|
||||||
- IOMMUNotifier *n;
|
|
||||||
-
|
|
||||||
- IOMMU_NOTIFIER_FOREACH(n, mr) {
|
|
||||||
- smmuv3_notify_asid(mr, n, asid);
|
|
||||||
- }
|
|
||||||
- }
|
|
||||||
- smmu_iotlb_inv_asid(s, asid);
|
|
||||||
-}
|
|
||||||
-
|
|
||||||
static int smmuv3_cmdq_consume(SMMUv3State *s)
|
|
||||||
{
|
|
||||||
SMMUState *bs = ARM_SMMU(s);
|
|
||||||
@@ -1072,7 +1031,8 @@ static int smmuv3_cmdq_consume(SMMUv3State *s)
|
|
||||||
uint16_t asid = CMD_ASID(&cmd);
|
|
||||||
|
|
||||||
trace_smmuv3_cmdq_tlbi_nh_asid(asid);
|
|
||||||
- smmuv3_s1_asid_inval(bs, asid);
|
|
||||||
+ smmu_inv_notifiers_all(&s->smmu_state);
|
|
||||||
+ smmu_iotlb_inv_asid(bs, asid);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case SMMU_CMD_TLBI_NH_ALL:
|
|
||||||
diff --git a/hw/arm/trace-events b/hw/arm/trace-events
|
|
||||||
index 1447ad5a90..2dee296c8f 100644
|
|
||||||
--- a/hw/arm/trace-events
|
|
||||||
+++ b/hw/arm/trace-events
|
|
||||||
@@ -46,7 +46,6 @@ smmuv3_cmdq_cfgi_cd(uint32_t sid) "sid=0x%x"
|
|
||||||
smmuv3_config_cache_hit(uint32_t sid, uint32_t hits, uint32_t misses, uint32_t perc) "Config cache HIT for sid=0x%x (hits=%d, misses=%d, hit rate=%d)"
|
|
||||||
smmuv3_config_cache_miss(uint32_t sid, uint32_t hits, uint32_t misses, uint32_t perc) "Config cache MISS for sid=0x%x (hits=%d, misses=%d, hit rate=%d)"
|
|
||||||
smmuv3_s1_range_inval(int vmid, int asid, uint64_t addr, uint8_t tg, uint64_t num_pages, uint8_t ttl, bool leaf) "vmid=%d asid=%d addr=0x%"PRIx64" tg=%d num_pages=0x%"PRIx64" ttl=%d leaf=%d"
|
|
||||||
-smmuv3_s1_asid_inval(int asid) "asid=%d"
|
|
||||||
smmuv3_cmdq_tlbi_nh(void) ""
|
|
||||||
smmuv3_cmdq_tlbi_nh_asid(uint16_t asid) "asid=%d"
|
|
||||||
smmuv3_config_cache_inv(uint32_t sid) "Config cache INV for sid=0x%x"
|
|
||||||
--
|
|
||||||
2.27.0
|
|
||||||
|
|
||||||
@ -1,157 +0,0 @@
|
|||||||
From 9682b8cd2454c00fbb4c4f7eb3e959187d9e6f1c Mon Sep 17 00:00:00 2001
|
|
||||||
From: Kunkun Jiang <jiangkunkun@huawei.com>
|
|
||||||
Date: Fri, 18 Nov 2022 15:22:31 +0800
|
|
||||||
Subject: [PATCH 13/36] Revert "hw/arm/smmuv3: Pass stage 1 configurations to
|
|
||||||
the host"
|
|
||||||
|
|
||||||
This reverts commit 2e5929ec2a35a7a227dc7ba70a557a84993a366d.
|
|
||||||
|
|
||||||
Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com>
|
|
||||||
---
|
|
||||||
hw/arm/smmu-internal.h | 1 -
|
|
||||||
hw/arm/smmuv3.c | 71 ++++++------------------------------------
|
|
||||||
hw/arm/trace-events | 1 -
|
|
||||||
3 files changed, 9 insertions(+), 64 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/hw/arm/smmu-internal.h b/hw/arm/smmu-internal.h
|
|
||||||
index 5ef8c598c6..2d75b31953 100644
|
|
||||||
--- a/hw/arm/smmu-internal.h
|
|
||||||
+++ b/hw/arm/smmu-internal.h
|
|
||||||
@@ -105,7 +105,6 @@ typedef struct SMMUIOTLBPageInvInfo {
|
|
||||||
} SMMUIOTLBPageInvInfo;
|
|
||||||
|
|
||||||
typedef struct SMMUSIDRange {
|
|
||||||
- SMMUState *state;
|
|
||||||
uint32_t start;
|
|
||||||
uint32_t end;
|
|
||||||
} SMMUSIDRange;
|
|
||||||
diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c
|
|
||||||
index 514ce9d57d..cceb3794d4 100644
|
|
||||||
--- a/hw/arm/smmuv3.c
|
|
||||||
+++ b/hw/arm/smmuv3.c
|
|
||||||
@@ -16,10 +16,6 @@
|
|
||||||
* with this program; if not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
-#ifdef __linux__
|
|
||||||
-#include "linux/iommu.h"
|
|
||||||
-#endif
|
|
||||||
-
|
|
||||||
#include "qemu/osdep.h"
|
|
||||||
#include "qemu/bitops.h"
|
|
||||||
#include "hw/irq.h"
|
|
||||||
@@ -936,61 +932,6 @@ static void smmuv3_s1_range_inval(SMMUState *s, Cmd *cmd)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
-static void smmuv3_notify_config_change(SMMUState *bs, uint32_t sid)
|
|
||||||
-{
|
|
||||||
-#ifdef __linux__
|
|
||||||
- IOMMUMemoryRegion *mr = smmu_iommu_mr(bs, sid);
|
|
||||||
- SMMUEventInfo event = {.type = SMMU_EVT_NONE, .sid = sid,
|
|
||||||
- .inval_ste_allowed = true};
|
|
||||||
- IOMMUConfig iommu_config = {};
|
|
||||||
- SMMUTransCfg *cfg;
|
|
||||||
- SMMUDevice *sdev;
|
|
||||||
-
|
|
||||||
- if (!mr) {
|
|
||||||
- return;
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
- sdev = container_of(mr, SMMUDevice, iommu);
|
|
||||||
-
|
|
||||||
- /* flush QEMU config cache */
|
|
||||||
- smmuv3_flush_config(sdev);
|
|
||||||
-
|
|
||||||
- if (!pci_device_is_pasid_ops_set(sdev->bus, sdev->devfn)) {
|
|
||||||
- return;
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
- cfg = smmuv3_get_config(sdev, &event);
|
|
||||||
-
|
|
||||||
- if (!cfg) {
|
|
||||||
- return;
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
- iommu_config.pasid_cfg.argsz = sizeof(struct iommu_pasid_table_config);
|
|
||||||
- iommu_config.pasid_cfg.version = PASID_TABLE_CFG_VERSION_1;
|
|
||||||
- iommu_config.pasid_cfg.format = IOMMU_PASID_FORMAT_SMMUV3;
|
|
||||||
- iommu_config.pasid_cfg.base_ptr = cfg->s1ctxptr;
|
|
||||||
- iommu_config.pasid_cfg.pasid_bits = 0;
|
|
||||||
- iommu_config.pasid_cfg.vendor_data.smmuv3.version = PASID_TABLE_SMMUV3_CFG_VERSION_1;
|
|
||||||
-
|
|
||||||
- if (cfg->disabled || cfg->bypassed) {
|
|
||||||
- iommu_config.pasid_cfg.config = IOMMU_PASID_CONFIG_BYPASS;
|
|
||||||
- } else if (cfg->aborted) {
|
|
||||||
- iommu_config.pasid_cfg.config = IOMMU_PASID_CONFIG_ABORT;
|
|
||||||
- } else {
|
|
||||||
- iommu_config.pasid_cfg.config = IOMMU_PASID_CONFIG_TRANSLATE;
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
- trace_smmuv3_notify_config_change(mr->parent_obj.name,
|
|
||||||
- iommu_config.pasid_cfg.config,
|
|
||||||
- iommu_config.pasid_cfg.base_ptr);
|
|
||||||
-
|
|
||||||
- if (pci_device_set_pasid_table(sdev->bus, sdev->devfn, &iommu_config)) {
|
|
||||||
- error_report("Failed to pass PASID table to host for iommu mr %s (%m)",
|
|
||||||
- mr->parent_obj.name);
|
|
||||||
- }
|
|
||||||
-#endif
|
|
||||||
-}
|
|
||||||
-
|
|
||||||
static gboolean
|
|
||||||
smmuv3_invalidate_ste(gpointer key, gpointer value, gpointer user_data)
|
|
||||||
{
|
|
||||||
@@ -1001,7 +942,6 @@ smmuv3_invalidate_ste(gpointer key, gpointer value, gpointer user_data)
|
|
||||||
if (sid < sid_range->start || sid > sid_range->end) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
- smmuv3_notify_config_change(sid_range->state, sid);
|
|
||||||
trace_smmuv3_config_cache_inv(sid);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
@@ -1072,14 +1012,22 @@ static int smmuv3_cmdq_consume(SMMUv3State *s)
|
|
||||||
case SMMU_CMD_CFGI_STE:
|
|
||||||
{
|
|
||||||
uint32_t sid = CMD_SID(&cmd);
|
|
||||||
+ IOMMUMemoryRegion *mr = smmu_iommu_mr(bs, sid);
|
|
||||||
+ SMMUDevice *sdev;
|
|
||||||
|
|
||||||
if (CMD_SSEC(&cmd)) {
|
|
||||||
cmd_error = SMMU_CERROR_ILL;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
+ if (!mr) {
|
|
||||||
+ break;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
trace_smmuv3_cmdq_cfgi_ste(sid);
|
|
||||||
- smmuv3_notify_config_change(bs, sid);
|
|
||||||
+ sdev = container_of(mr, SMMUDevice, iommu);
|
|
||||||
+ smmuv3_flush_config(sdev);
|
|
||||||
+
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case SMMU_CMD_CFGI_STE_RANGE: /* same as SMMU_CMD_CFGI_ALL */
|
|
||||||
@@ -1094,7 +1042,6 @@ static int smmuv3_cmdq_consume(SMMUv3State *s)
|
|
||||||
}
|
|
||||||
|
|
||||||
mask = (1ULL << (range + 1)) - 1;
|
|
||||||
- sid_range.state = bs;
|
|
||||||
sid_range.start = sid & ~mask;
|
|
||||||
sid_range.end = sid_range.start + mask;
|
|
||||||
|
|
||||||
diff --git a/hw/arm/trace-events b/hw/arm/trace-events
|
|
||||||
index d9851d663e..1447ad5a90 100644
|
|
||||||
--- a/hw/arm/trace-events
|
|
||||||
+++ b/hw/arm/trace-events
|
|
||||||
@@ -53,5 +53,4 @@ smmuv3_config_cache_inv(uint32_t sid) "Config cache INV for sid=0x%x"
|
|
||||||
smmuv3_notify_flag_add(const char *iommu) "ADD SMMUNotifier node for iommu mr=%s"
|
|
||||||
smmuv3_notify_flag_del(const char *iommu) "DEL SMMUNotifier node for iommu mr=%s"
|
|
||||||
smmuv3_inv_notifiers_iova(const char *name, uint16_t asid, uint64_t iova, uint8_t tg, uint64_t num_pages) "iommu mr=%s asid=%d iova=0x%"PRIx64" tg=%d num_pages=0x%"PRIx64
|
|
||||||
-smmuv3_notify_config_change(const char *name, uint8_t config, uint64_t s1ctxptr) "iommu mr=%s config=%d s1ctxptr=0x%"PRIx64
|
|
||||||
|
|
||||||
--
|
|
||||||
2.27.0
|
|
||||||
|
|
||||||
@ -1,105 +0,0 @@
|
|||||||
From c3dab32ec9b111e036b7de9cb8cb5a987b1764f3 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Kunkun Jiang <jiangkunkun@huawei.com>
|
|
||||||
Date: Fri, 18 Nov 2022 15:22:16 +0800
|
|
||||||
Subject: [PATCH 03/36] Revert "hw/arm/smmuv3: Post-load stage 1 configurations
|
|
||||||
to the host"
|
|
||||||
|
|
||||||
This reverts commit 1b95c995f032c21bf6607dda8ede0f5856bb190a.
|
|
||||||
|
|
||||||
Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com>
|
|
||||||
---
|
|
||||||
hw/arm/smmuv3.c | 33 +++++----------------------------
|
|
||||||
1 file changed, 5 insertions(+), 28 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c
|
|
||||||
index 2bd9f22055..55e78db65d 100644
|
|
||||||
--- a/hw/arm/smmuv3.c
|
|
||||||
+++ b/hw/arm/smmuv3.c
|
|
||||||
@@ -936,7 +936,7 @@ static void smmuv3_s1_range_inval(SMMUState *s, Cmd *cmd)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
-static int smmuv3_notify_config_change(SMMUState *bs, uint32_t sid)
|
|
||||||
+static void smmuv3_notify_config_change(SMMUState *bs, uint32_t sid)
|
|
||||||
{
|
|
||||||
#ifdef __linux__
|
|
||||||
IOMMUMemoryRegion *mr = smmu_iommu_mr(bs, sid);
|
|
||||||
@@ -945,10 +945,9 @@ static int smmuv3_notify_config_change(SMMUState *bs, uint32_t sid)
|
|
||||||
IOMMUConfig iommu_config = {};
|
|
||||||
SMMUTransCfg *cfg;
|
|
||||||
SMMUDevice *sdev;
|
|
||||||
- int ret;
|
|
||||||
|
|
||||||
if (!mr) {
|
|
||||||
- return 0;
|
|
||||||
+ return;
|
|
||||||
}
|
|
||||||
|
|
||||||
sdev = container_of(mr, SMMUDevice, iommu);
|
|
||||||
@@ -957,13 +956,13 @@ static int smmuv3_notify_config_change(SMMUState *bs, uint32_t sid)
|
|
||||||
smmuv3_flush_config(sdev);
|
|
||||||
|
|
||||||
if (!pci_device_is_pasid_ops_set(sdev->bus, sdev->devfn)) {
|
|
||||||
- return 0;
|
|
||||||
+ return;
|
|
||||||
}
|
|
||||||
|
|
||||||
cfg = smmuv3_get_config(sdev, &event);
|
|
||||||
|
|
||||||
if (!cfg) {
|
|
||||||
- return 0;
|
|
||||||
+ return;
|
|
||||||
}
|
|
||||||
|
|
||||||
iommu_config.pasid_cfg.argsz = sizeof(struct iommu_pasid_table_config);
|
|
||||||
@@ -985,13 +984,10 @@ static int smmuv3_notify_config_change(SMMUState *bs, uint32_t sid)
|
|
||||||
iommu_config.pasid_cfg.config,
|
|
||||||
iommu_config.pasid_cfg.base_ptr);
|
|
||||||
|
|
||||||
- ret = pci_device_set_pasid_table(sdev->bus, sdev->devfn, &iommu_config);
|
|
||||||
- if (ret) {
|
|
||||||
+ if (pci_device_set_pasid_table(sdev->bus, sdev->devfn, &iommu_config)) {
|
|
||||||
error_report("Failed to pass PASID table to host for iommu mr %s (%m)",
|
|
||||||
mr->parent_obj.name);
|
|
||||||
}
|
|
||||||
-
|
|
||||||
- return ret;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1561,24 +1557,6 @@ static void smmu_realize(DeviceState *d, Error **errp)
|
|
||||||
smmu_init_irq(s, dev);
|
|
||||||
}
|
|
||||||
|
|
||||||
-static int smmuv3_post_load(void *opaque, int version_id)
|
|
||||||
-{
|
|
||||||
- SMMUv3State *s3 = opaque;
|
|
||||||
- SMMUState *s = &(s3->smmu_state);
|
|
||||||
- SMMUDevice *sdev;
|
|
||||||
- int ret = 0;
|
|
||||||
-
|
|
||||||
- QLIST_FOREACH(sdev, &s->devices_with_notifiers, next) {
|
|
||||||
- uint32_t sid = smmu_get_sid(sdev);
|
|
||||||
- ret = smmuv3_notify_config_change(s, sid);
|
|
||||||
- if (ret) {
|
|
||||||
- break;
|
|
||||||
- }
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
- return ret;
|
|
||||||
-}
|
|
||||||
-
|
|
||||||
static const VMStateDescription vmstate_smmuv3_queue = {
|
|
||||||
.name = "smmuv3_queue",
|
|
||||||
.version_id = 1,
|
|
||||||
@@ -1597,7 +1575,6 @@ static const VMStateDescription vmstate_smmuv3 = {
|
|
||||||
.version_id = 1,
|
|
||||||
.minimum_version_id = 1,
|
|
||||||
.priority = MIG_PRI_IOMMU,
|
|
||||||
- .post_load = smmuv3_post_load,
|
|
||||||
.fields = (VMStateField[]) {
|
|
||||||
VMSTATE_UINT32(features, SMMUv3State),
|
|
||||||
VMSTATE_UINT8(sid_size, SMMUv3State),
|
|
||||||
--
|
|
||||||
2.27.0
|
|
||||||
|
|
||||||
@ -1,41 +0,0 @@
|
|||||||
From 7d0023ef0c909bc569477e7676bc4c43734783a3 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Kunkun Jiang <jiangkunkun@huawei.com>
|
|
||||||
Date: Fri, 18 Nov 2022 15:22:35 +0800
|
|
||||||
Subject: [PATCH 16/36] Revert "hw/arm/smmuv3: Store the PASID table GPA in the
|
|
||||||
translation config"
|
|
||||||
|
|
||||||
This reverts commit f937ce4124d57eea27d516957a2efa0e7fbdf198.
|
|
||||||
|
|
||||||
Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com>
|
|
||||||
---
|
|
||||||
hw/arm/smmuv3.c | 1 -
|
|
||||||
include/hw/arm/smmu-common.h | 1 -
|
|
||||||
2 files changed, 2 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c
|
|
||||||
index e09e54a9aa..275f1db430 100644
|
|
||||||
--- a/hw/arm/smmuv3.c
|
|
||||||
+++ b/hw/arm/smmuv3.c
|
|
||||||
@@ -362,7 +362,6 @@ static int decode_ste(SMMUv3State *s, SMMUTransCfg *cfg,
|
|
||||||
"SMMUv3 S1 stalling fault model not allowed yet\n");
|
|
||||||
goto bad_ste;
|
|
||||||
}
|
|
||||||
- cfg->s1ctxptr = STE_CTXPTR(ste);
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
bad_ste:
|
|
||||||
diff --git a/include/hw/arm/smmu-common.h b/include/hw/arm/smmu-common.h
|
|
||||||
index d578339935..706be3c6d0 100644
|
|
||||||
--- a/include/hw/arm/smmu-common.h
|
|
||||||
+++ b/include/hw/arm/smmu-common.h
|
|
||||||
@@ -76,7 +76,6 @@ typedef struct SMMUTransCfg {
|
|
||||||
uint8_t tbi; /* Top Byte Ignore */
|
|
||||||
uint16_t asid;
|
|
||||||
SMMUTransTableInfo tt[2];
|
|
||||||
- dma_addr_t s1ctxptr;
|
|
||||||
uint32_t iotlb_hits; /* counts IOTLB hits for this asid */
|
|
||||||
uint32_t iotlb_misses; /* counts IOTLB misses for this asid */
|
|
||||||
} SMMUTransCfg;
|
|
||||||
--
|
|
||||||
2.27.0
|
|
||||||
|
|
||||||
@ -1,49 +0,0 @@
|
|||||||
From f66f64cf3ca968db2ca7f45bfd125ec7d85624e5 Mon Sep 17 00:00:00 2001
|
|
||||||
From: jiangdongxu <jiangdongxu1@huawei.com>
|
|
||||||
Date: Mon, 4 Dec 2023 17:30:02 +0800
|
|
||||||
Subject: [PATCH] Revert "hw/virtio/virtio-iommu-pci: Enforce the device is
|
|
||||||
plugged on the root bus"
|
|
||||||
|
|
||||||
This reverts commit a2323aa79da71c92e818306f1e18184619309a35.
|
|
||||||
|
|
||||||
Signed-off-by: jiangdongxu <jiangdongxu1@huawei.com>
|
|
||||||
---
|
|
||||||
hw/virtio/virtio-iommu-pci.c | 13 +++----------
|
|
||||||
1 file changed, 3 insertions(+), 10 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/hw/virtio/virtio-iommu-pci.c b/hw/virtio/virtio-iommu-pci.c
|
|
||||||
index 37eb2fb979..a160ae6b41 100644
|
|
||||||
--- a/hw/virtio/virtio-iommu-pci.c
|
|
||||||
+++ b/hw/virtio/virtio-iommu-pci.c
|
|
||||||
@@ -44,7 +44,6 @@ static Property virtio_iommu_pci_properties[] = {
|
|
||||||
static void virtio_iommu_pci_realize(VirtIOPCIProxy *vpci_dev, Error **errp)
|
|
||||||
{
|
|
||||||
VirtIOIOMMUPCI *dev = VIRTIO_IOMMU_PCI(vpci_dev);
|
|
||||||
- PCIBus *pbus = pci_get_bus(&vpci_dev->pci_dev);
|
|
||||||
DeviceState *vdev = DEVICE(&dev->vdev);
|
|
||||||
VirtIOIOMMU *s = VIRTIO_IOMMU(vdev);
|
|
||||||
|
|
||||||
@@ -66,17 +65,11 @@ static void virtio_iommu_pci_realize(VirtIOPCIProxy *vpci_dev, Error **errp)
|
|
||||||
s->reserved_regions[i].type != VIRTIO_IOMMU_RESV_MEM_T_MSI) {
|
|
||||||
error_setg(errp, "reserved region %d has an invalid type", i);
|
|
||||||
error_append_hint(errp, "Valid values are 0 and 1\n");
|
|
||||||
- return;
|
|
||||||
- }
|
|
||||||
+ }
|
|
||||||
}
|
|
||||||
- if (!pci_bus_is_root(pbus)) {
|
|
||||||
- error_setg(errp, "virtio-iommu-pci must be plugged on the root bus");
|
|
||||||
- return;
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
object_property_set_link(OBJECT(dev), "primary-bus",
|
|
||||||
- OBJECT(pbus), &error_abort);
|
|
||||||
-
|
|
||||||
+ OBJECT(pci_get_bus(&vpci_dev->pci_dev)),
|
|
||||||
+ &error_abort);
|
|
||||||
virtio_pci_force_virtio_1(vpci_dev);
|
|
||||||
qdev_realize(vdev, BUS(&vpci_dev->bus), errp);
|
|
||||||
}
|
|
||||||
--
|
|
||||||
2.27.0
|
|
||||||
|
|
||||||
@ -1,50 +0,0 @@
|
|||||||
From 2916e0465befa35df9cce14b761177be55ccce4d Mon Sep 17 00:00:00 2001
|
|
||||||
From: Kunkun Jiang <jiangkunkun@huawei.com>
|
|
||||||
Date: Fri, 18 Nov 2022 15:22:50 +0800
|
|
||||||
Subject: [PATCH 28/36] Revert "iommu: Introduce generic header"
|
|
||||||
|
|
||||||
This reverts commit 5e312f7b41ec48dc7dc9805af9f52aa8ed393bf9.
|
|
||||||
|
|
||||||
Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com>
|
|
||||||
---
|
|
||||||
include/hw/iommu/iommu.h | 28 ----------------------------
|
|
||||||
1 file changed, 28 deletions(-)
|
|
||||||
delete mode 100644 include/hw/iommu/iommu.h
|
|
||||||
|
|
||||||
diff --git a/include/hw/iommu/iommu.h b/include/hw/iommu/iommu.h
|
|
||||||
deleted file mode 100644
|
|
||||||
index 12092bda7b..0000000000
|
|
||||||
--- a/include/hw/iommu/iommu.h
|
|
||||||
+++ /dev/null
|
|
||||||
@@ -1,28 +0,0 @@
|
|
||||||
-/*
|
|
||||||
- * common header for iommu devices
|
|
||||||
- *
|
|
||||||
- * Copyright Red Hat, Inc. 2019
|
|
||||||
- *
|
|
||||||
- * Authors:
|
|
||||||
- * Eric Auger <eric.auger@redhat.com>
|
|
||||||
- *
|
|
||||||
- * This work is licensed under the terms of the GNU GPL, version 2. See
|
|
||||||
- * the COPYING file in the top-level directory.
|
|
||||||
- */
|
|
||||||
-
|
|
||||||
-#ifndef QEMU_HW_IOMMU_IOMMU_H
|
|
||||||
-#define QEMU_HW_IOMMU_IOMMU_H
|
|
||||||
-#ifdef __linux__
|
|
||||||
-#include <linux/iommu.h>
|
|
||||||
-#endif
|
|
||||||
-
|
|
||||||
-typedef struct IOMMUConfig {
|
|
||||||
- union {
|
|
||||||
-#ifdef __linux__
|
|
||||||
- struct iommu_pasid_table_config pasid_cfg;
|
|
||||||
-#endif
|
|
||||||
- };
|
|
||||||
-} IOMMUConfig;
|
|
||||||
-
|
|
||||||
-
|
|
||||||
-#endif /* QEMU_HW_IOMMU_IOMMU_H */
|
|
||||||
--
|
|
||||||
2.27.0
|
|
||||||
|
|
||||||
@ -1,28 +0,0 @@
|
|||||||
From eb4958875239ccfabc03f28738d520c75db638d5 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Kunkun Jiang <jiangkunkun@huawei.com>
|
|
||||||
Date: Fri, 18 Nov 2022 15:22:52 +0800
|
|
||||||
Subject: [PATCH 30/36] Revert "memory: Add IOMMU_ATTR_MSI_TRANSLATE IOMMU
|
|
||||||
memory region attribute"
|
|
||||||
|
|
||||||
This reverts commit 062923fd4e6d11e1b724f2dd059f8b0c6e65bf7a.
|
|
||||||
|
|
||||||
Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com>
|
|
||||||
---
|
|
||||||
include/exec/memory.h | 1 -
|
|
||||||
1 file changed, 1 deletion(-)
|
|
||||||
|
|
||||||
diff --git a/include/exec/memory.h b/include/exec/memory.h
|
|
||||||
index 67d9061766..229c9cf85b 100644
|
|
||||||
--- a/include/exec/memory.h
|
|
||||||
+++ b/include/exec/memory.h
|
|
||||||
@@ -326,7 +326,6 @@ typedef struct MemoryRegionClass {
|
|
||||||
enum IOMMUMemoryRegionAttr {
|
|
||||||
IOMMU_ATTR_SPAPR_TCE_FD,
|
|
||||||
IOMMU_ATTR_VFIO_NESTED,
|
|
||||||
- IOMMU_ATTR_MSI_TRANSLATE,
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
--
|
|
||||||
2.27.0
|
|
||||||
|
|
||||||
@ -1,61 +0,0 @@
|
|||||||
From 4c9e81175e15ca78c7ba7090ec20ea10c9e12751 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Kunkun Jiang <jiangkunkun@huawei.com>
|
|
||||||
Date: Fri, 18 Nov 2022 15:22:53 +0800
|
|
||||||
Subject: [PATCH 31/36] Revert "memory: Add IOMMU_ATTR_VFIO_NESTED IOMMU memory
|
|
||||||
region attribute"
|
|
||||||
|
|
||||||
This reverts commit b380e3e0c30fb68dbbfb1397f3c374adfff77ac4.
|
|
||||||
|
|
||||||
Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com>
|
|
||||||
---
|
|
||||||
hw/arm/smmuv3.c | 12 ------------
|
|
||||||
include/exec/memory.h | 3 +--
|
|
||||||
2 files changed, 1 insertion(+), 14 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c
|
|
||||||
index 5a092506d3..f4de66827d 100644
|
|
||||||
--- a/hw/arm/smmuv3.c
|
|
||||||
+++ b/hw/arm/smmuv3.c
|
|
||||||
@@ -1593,17 +1593,6 @@ static int smmuv3_notify_flag_changed(IOMMUMemoryRegion *iommu,
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
-static int smmuv3_get_attr(IOMMUMemoryRegion *iommu,
|
|
||||||
- enum IOMMUMemoryRegionAttr attr,
|
|
||||||
- void *data)
|
|
||||||
-{
|
|
||||||
- if (attr == IOMMU_ATTR_VFIO_NESTED) {
|
|
||||||
- *(bool *) data = true;
|
|
||||||
- return 0;
|
|
||||||
- }
|
|
||||||
- return -EINVAL;
|
|
||||||
-}
|
|
||||||
-
|
|
||||||
static void smmuv3_iommu_memory_region_class_init(ObjectClass *klass,
|
|
||||||
void *data)
|
|
||||||
{
|
|
||||||
@@ -1611,7 +1600,6 @@ static void smmuv3_iommu_memory_region_class_init(ObjectClass *klass,
|
|
||||||
|
|
||||||
imrc->translate = smmuv3_translate;
|
|
||||||
imrc->notify_flag_changed = smmuv3_notify_flag_changed;
|
|
||||||
- imrc->get_attr = smmuv3_get_attr;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const TypeInfo smmuv3_type_info = {
|
|
||||||
diff --git a/include/exec/memory.h b/include/exec/memory.h
|
|
||||||
index 229c9cf85b..273f7f45d3 100644
|
|
||||||
--- a/include/exec/memory.h
|
|
||||||
+++ b/include/exec/memory.h
|
|
||||||
@@ -324,8 +324,7 @@ typedef struct MemoryRegionClass {
|
|
||||||
|
|
||||||
|
|
||||||
enum IOMMUMemoryRegionAttr {
|
|
||||||
- IOMMU_ATTR_SPAPR_TCE_FD,
|
|
||||||
- IOMMU_ATTR_VFIO_NESTED,
|
|
||||||
+ IOMMU_ATTR_SPAPR_TCE_FD
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
--
|
|
||||||
2.27.0
|
|
||||||
|
|
||||||
@ -1,166 +0,0 @@
|
|||||||
From 8cc370faf56aeaa060e1b4d9a307075bae982563 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Kunkun Jiang <jiangkunkun@huawei.com>
|
|
||||||
Date: Fri, 18 Nov 2022 15:22:57 +0800
|
|
||||||
Subject: [PATCH 34/36] Revert "memory: Add new fields in IOTLBEntry"
|
|
||||||
|
|
||||||
This reverts commit da97cef20d4ee5a8f3942953836b35e7f7dd974f.
|
|
||||||
|
|
||||||
Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com>
|
|
||||||
---
|
|
||||||
hw/arm/smmu-common.c | 2 +-
|
|
||||||
hw/arm/smmuv3.c | 2 +-
|
|
||||||
hw/i386/intel_iommu.c | 6 +++---
|
|
||||||
hw/ppc/spapr_iommu.c | 2 +-
|
|
||||||
hw/virtio/virtio-iommu.c | 4 ++--
|
|
||||||
include/exec/memory.h | 36 +-----------------------------------
|
|
||||||
6 files changed, 9 insertions(+), 43 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/hw/arm/smmu-common.c b/hw/arm/smmu-common.c
|
|
||||||
index 730dd20db1..e09b9c13b7 100644
|
|
||||||
--- a/hw/arm/smmu-common.c
|
|
||||||
+++ b/hw/arm/smmu-common.c
|
|
||||||
@@ -471,7 +471,7 @@ IOMMUMemoryRegion *smmu_iommu_mr(SMMUState *s, uint32_t sid)
|
|
||||||
/* Unmap the whole notifier's range */
|
|
||||||
static void smmu_unmap_notifier_range(IOMMUNotifier *n)
|
|
||||||
{
|
|
||||||
- IOMMUTLBEvent event = {};
|
|
||||||
+ IOMMUTLBEvent event;
|
|
||||||
|
|
||||||
event.type = IOMMU_NOTIFIER_UNMAP;
|
|
||||||
event.entry.target_as = &address_space_memory;
|
|
||||||
diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c
|
|
||||||
index 0e8fe646aa..3b43368be0 100644
|
|
||||||
--- a/hw/arm/smmuv3.c
|
|
||||||
+++ b/hw/arm/smmuv3.c
|
|
||||||
@@ -806,7 +806,7 @@ static void smmuv3_notify_iova(IOMMUMemoryRegion *mr,
|
|
||||||
uint8_t tg, uint64_t num_pages)
|
|
||||||
{
|
|
||||||
SMMUDevice *sdev = container_of(mr, SMMUDevice, iommu);
|
|
||||||
- IOMMUTLBEvent event = {};
|
|
||||||
+ IOMMUTLBEvent event;
|
|
||||||
uint8_t granule;
|
|
||||||
|
|
||||||
if (!tg) {
|
|
||||||
diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c
|
|
||||||
index 6501d93f7e..5b865ac08c 100644
|
|
||||||
--- a/hw/i386/intel_iommu.c
|
|
||||||
+++ b/hw/i386/intel_iommu.c
|
|
||||||
@@ -1197,7 +1197,7 @@ static int vtd_page_walk_level(dma_addr_t addr, uint64_t start,
|
|
||||||
uint32_t offset;
|
|
||||||
uint64_t slpte;
|
|
||||||
uint64_t subpage_size, subpage_mask;
|
|
||||||
- IOMMUTLBEvent event = {};
|
|
||||||
+ IOMMUTLBEvent event;
|
|
||||||
uint64_t iova = start;
|
|
||||||
uint64_t iova_next;
|
|
||||||
int ret = 0;
|
|
||||||
@@ -2431,7 +2431,7 @@ static bool vtd_process_device_iotlb_desc(IntelIOMMUState *s,
|
|
||||||
VTDInvDesc *inv_desc)
|
|
||||||
{
|
|
||||||
VTDAddressSpace *vtd_dev_as;
|
|
||||||
- IOMMUTLBEvent event = {};
|
|
||||||
+ IOMMUTLBEvent event;
|
|
||||||
struct VTDBus *vtd_bus;
|
|
||||||
hwaddr addr;
|
|
||||||
uint64_t sz;
|
|
||||||
@@ -3487,7 +3487,7 @@ static void vtd_address_space_unmap(VTDAddressSpace *as, IOMMUNotifier *n)
|
|
||||||
size = remain = end - start + 1;
|
|
||||||
|
|
||||||
while (remain >= VTD_PAGE_SIZE) {
|
|
||||||
- IOMMUTLBEvent event = {};
|
|
||||||
+ IOMMUTLBEvent event;
|
|
||||||
uint64_t mask = dma_aligned_pow2_mask(start, end, s->aw_bits);
|
|
||||||
uint64_t size = mask + 1;
|
|
||||||
|
|
||||||
diff --git a/hw/ppc/spapr_iommu.c b/hw/ppc/spapr_iommu.c
|
|
||||||
index 454df25d44..db01071858 100644
|
|
||||||
--- a/hw/ppc/spapr_iommu.c
|
|
||||||
+++ b/hw/ppc/spapr_iommu.c
|
|
||||||
@@ -449,7 +449,7 @@ static void spapr_tce_reset(DeviceState *dev)
|
|
||||||
static target_ulong put_tce_emu(SpaprTceTable *tcet, target_ulong ioba,
|
|
||||||
target_ulong tce)
|
|
||||||
{
|
|
||||||
- IOMMUTLBEvent event = {};
|
|
||||||
+ IOMMUTLBEvent event;
|
|
||||||
hwaddr page_mask = IOMMU_PAGE_MASK(tcet->page_shift);
|
|
||||||
unsigned long index = (ioba - tcet->bus_offset) >> tcet->page_shift;
|
|
||||||
|
|
||||||
diff --git a/hw/virtio/virtio-iommu.c b/hw/virtio/virtio-iommu.c
|
|
||||||
index 83ed2b82e6..1b23e8e18c 100644
|
|
||||||
--- a/hw/virtio/virtio-iommu.c
|
|
||||||
+++ b/hw/virtio/virtio-iommu.c
|
|
||||||
@@ -129,7 +129,7 @@ static void virtio_iommu_notify_map(IOMMUMemoryRegion *mr, hwaddr virt_start,
|
|
||||||
hwaddr virt_end, hwaddr paddr,
|
|
||||||
uint32_t flags)
|
|
||||||
{
|
|
||||||
- IOMMUTLBEvent event = {};
|
|
||||||
+ IOMMUTLBEvent event;
|
|
||||||
IOMMUAccessFlags perm = IOMMU_ACCESS_FLAG(flags & VIRTIO_IOMMU_MAP_F_READ,
|
|
||||||
flags & VIRTIO_IOMMU_MAP_F_WRITE);
|
|
||||||
|
|
||||||
@@ -154,7 +154,7 @@ static void virtio_iommu_notify_map(IOMMUMemoryRegion *mr, hwaddr virt_start,
|
|
||||||
static void virtio_iommu_notify_unmap(IOMMUMemoryRegion *mr, hwaddr virt_start,
|
|
||||||
hwaddr virt_end)
|
|
||||||
{
|
|
||||||
- IOMMUTLBEvent event = {};
|
|
||||||
+ IOMMUTLBEvent event;
|
|
||||||
uint64_t delta = virt_end - virt_start;
|
|
||||||
|
|
||||||
if (!(mr->iommu_notify_flags & IOMMU_NOTIFIER_UNMAP)) {
|
|
||||||
diff --git a/include/exec/memory.h b/include/exec/memory.h
|
|
||||||
index 273f7f45d3..4b5b431e45 100644
|
|
||||||
--- a/include/exec/memory.h
|
|
||||||
+++ b/include/exec/memory.h
|
|
||||||
@@ -116,48 +116,14 @@ typedef enum {
|
|
||||||
IOMMU_RW = 3,
|
|
||||||
} IOMMUAccessFlags;
|
|
||||||
|
|
||||||
-/* Granularity of the cache invalidation */
|
|
||||||
-typedef enum {
|
|
||||||
- IOMMU_INV_GRAN_ADDR = 0,
|
|
||||||
- IOMMU_INV_GRAN_PASID,
|
|
||||||
- IOMMU_INV_GRAN_DOMAIN,
|
|
||||||
-} IOMMUInvGranularity;
|
|
||||||
-
|
|
||||||
#define IOMMU_ACCESS_FLAG(r, w) (((r) ? IOMMU_RO : 0) | ((w) ? IOMMU_WO : 0))
|
|
||||||
|
|
||||||
-/**
|
|
||||||
- * struct IOMMUTLBEntry - IOMMU TLB entry
|
|
||||||
- *
|
|
||||||
- * Structure used when performing a translation or when notifying MAP or
|
|
||||||
- * UNMAP (invalidation) events
|
|
||||||
- *
|
|
||||||
- * @target_as: target address space
|
|
||||||
- * @iova: IO virtual address (input)
|
|
||||||
- * @translated_addr: translated address (output)
|
|
||||||
- * @addr_mask: address mask (0xfff means 4K binding), must be multiple of 2
|
|
||||||
- * @perm: permission flag of the mapping (NONE encodes no mapping or
|
|
||||||
- * invalidation notification)
|
|
||||||
- * @granularity: granularity of the invalidation
|
|
||||||
- * @flags: informs whether the following fields are set
|
|
||||||
- * @arch_id: architecture specific ID tagging the TLB
|
|
||||||
- * @pasid: PASID tagging the TLB
|
|
||||||
- * @leaf: when @perm is NONE, indicates whether only caches for the last
|
|
||||||
- * level of translation need to be invalidated.
|
|
||||||
- */
|
|
||||||
struct IOMMUTLBEntry {
|
|
||||||
AddressSpace *target_as;
|
|
||||||
hwaddr iova;
|
|
||||||
hwaddr translated_addr;
|
|
||||||
- hwaddr addr_mask;
|
|
||||||
+ hwaddr addr_mask; /* 0xfff = 4k translation */
|
|
||||||
IOMMUAccessFlags perm;
|
|
||||||
- IOMMUInvGranularity granularity;
|
|
||||||
-#define IOMMU_INV_FLAGS_PASID (1 << 0)
|
|
||||||
-#define IOMMU_INV_FLAGS_ARCHID (1 << 1)
|
|
||||||
-#define IOMMU_INV_FLAGS_LEAF (1 << 2)
|
|
||||||
- uint32_t flags;
|
|
||||||
- uint32_t arch_id;
|
|
||||||
- uint32_t pasid;
|
|
||||||
- bool leaf;
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
--
|
|
||||||
2.27.0
|
|
||||||
|
|
||||||
@ -1,87 +0,0 @@
|
|||||||
From 3ab99dc1bf580607791aa402ad330720ce993ae2 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Kunkun Jiang <jiangkunkun@huawei.com>
|
|
||||||
Date: Fri, 18 Nov 2022 15:22:51 +0800
|
|
||||||
Subject: [PATCH 29/36] Revert "memory: Introduce IOMMU Memory Region
|
|
||||||
inject_faults API"
|
|
||||||
|
|
||||||
This reverts commit d2dce19165f133935ff72e209f19bc43ab4d1421.
|
|
||||||
|
|
||||||
Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com>
|
|
||||||
---
|
|
||||||
include/exec/memory.h | 24 ------------------------
|
|
||||||
softmmu/memory.c | 10 ----------
|
|
||||||
2 files changed, 34 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/include/exec/memory.h b/include/exec/memory.h
|
|
||||||
index 7c3fe69d52..67d9061766 100644
|
|
||||||
--- a/include/exec/memory.h
|
|
||||||
+++ b/include/exec/memory.h
|
|
||||||
@@ -106,8 +106,6 @@ struct MemoryRegionSection {
|
|
||||||
bool nonvolatile;
|
|
||||||
};
|
|
||||||
|
|
||||||
-struct iommu_fault;
|
|
||||||
-
|
|
||||||
typedef struct IOMMUTLBEntry IOMMUTLBEntry;
|
|
||||||
|
|
||||||
/* See address_space_translate: bit 0 is read, bit 1 is write. */
|
|
||||||
@@ -528,19 +526,6 @@ struct IOMMUMemoryRegionClass {
|
|
||||||
int (*iommu_set_page_size_mask)(IOMMUMemoryRegion *iommu,
|
|
||||||
uint64_t page_size_mask,
|
|
||||||
Error **errp);
|
|
||||||
-
|
|
||||||
- /*
|
|
||||||
- * Inject @count faults into the IOMMU memory region
|
|
||||||
- *
|
|
||||||
- * Optional method: if this method is not provided, then
|
|
||||||
- * memory_region_injection_faults() will return -ENOENT
|
|
||||||
- *
|
|
||||||
- * @iommu: the IOMMU memory region to inject the faults in
|
|
||||||
- * @count: number of faults to inject
|
|
||||||
- * @buf: fault buffer
|
|
||||||
- */
|
|
||||||
- int (*inject_faults)(IOMMUMemoryRegion *iommu, int count,
|
|
||||||
- struct iommu_fault *buf);
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef struct RamDiscardListener RamDiscardListener;
|
|
||||||
@@ -1837,15 +1822,6 @@ int memory_region_iommu_num_indexes(IOMMUMemoryRegion *iommu_mr);
|
|
||||||
int memory_region_iommu_set_page_size_mask(IOMMUMemoryRegion *iommu_mr,
|
|
||||||
uint64_t page_size_mask,
|
|
||||||
Error **errp);
|
|
||||||
-/**
|
|
||||||
- * memory_region_inject_faults : inject @count faults stored in @buf
|
|
||||||
- *
|
|
||||||
- * @iommu_mr: the IOMMU memory region
|
|
||||||
- * @count: number of faults to be injected
|
|
||||||
- * @buf: buffer containing the faults
|
|
||||||
- */
|
|
||||||
-int memory_region_inject_faults(IOMMUMemoryRegion *iommu_mr, int count,
|
|
||||||
- struct iommu_fault *buf);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* memory_region_name: get a memory region's name
|
|
||||||
diff --git a/softmmu/memory.c b/softmmu/memory.c
|
|
||||||
index 9f98209ab2..7340e19ff5 100644
|
|
||||||
--- a/softmmu/memory.c
|
|
||||||
+++ b/softmmu/memory.c
|
|
||||||
@@ -2111,16 +2111,6 @@ void ram_discard_manager_unregister_listener(RamDiscardManager *rdm,
|
|
||||||
rdmc->unregister_listener(rdm, rdl);
|
|
||||||
}
|
|
||||||
|
|
||||||
-int memory_region_inject_faults(IOMMUMemoryRegion *iommu_mr, int count,
|
|
||||||
- struct iommu_fault *buf)
|
|
||||||
-{
|
|
||||||
- IOMMUMemoryRegionClass *imrc = IOMMU_MEMORY_REGION_GET_CLASS(iommu_mr);
|
|
||||||
- if (!imrc->inject_faults) {
|
|
||||||
- return -ENOENT;
|
|
||||||
- }
|
|
||||||
- return imrc->inject_faults(iommu_mr, count, buf);
|
|
||||||
-}
|
|
||||||
-
|
|
||||||
void memory_region_set_log(MemoryRegion *mr, bool log, unsigned client)
|
|
||||||
{
|
|
||||||
uint8_t mask = 1 << client;
|
|
||||||
--
|
|
||||||
2.27.0
|
|
||||||
|
|
||||||
@ -1,31 +0,0 @@
|
|||||||
From e42b57adeac96c7d39b1c032ab3b66b7eff18cc8 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Yan Wang <wangyan122@huawei.com>
|
|
||||||
Date: Tue, 29 Mar 2022 15:18:56 +0800
|
|
||||||
Subject: [PATCH 2/2] Revert "monitor: limit io error qmp event to at most once
|
|
||||||
per 60s"
|
|
||||||
|
|
||||||
This reverts commit 44f45b5c163efed5387dac40e229e0a50bf5921a.
|
|
||||||
|
|
||||||
The commit 44f45b5c will reduse the IO-hang related log, which
|
|
||||||
is useful to solve the problem.
|
|
||||||
|
|
||||||
Signed-off-by: Yan Wang <wangyan122@huawei.com>
|
|
||||||
---
|
|
||||||
monitor/monitor.c | 1 -
|
|
||||||
1 file changed, 1 deletion(-)
|
|
||||||
|
|
||||||
diff --git a/monitor/monitor.c b/monitor/monitor.c
|
|
||||||
index 28206bedc4..257ef4ee54 100644
|
|
||||||
--- a/monitor/monitor.c
|
|
||||||
+++ b/monitor/monitor.c
|
|
||||||
@@ -301,7 +301,6 @@ static MonitorQAPIEventConf monitor_qapi_event_conf[QAPI_EVENT__MAX] = {
|
|
||||||
[QAPI_EVENT_QUORUM_FAILURE] = { 1000 * SCALE_MS },
|
|
||||||
[QAPI_EVENT_VSERPORT_CHANGE] = { 1000 * SCALE_MS },
|
|
||||||
[QAPI_EVENT_MEMORY_DEVICE_SIZE_CHANGE] = { 1000 * SCALE_MS },
|
|
||||||
- [QAPI_EVENT_BLOCK_IO_ERROR] = { 60L * 1000 * SCALE_MS },
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
--
|
|
||||||
2.27.0
|
|
||||||
|
|
||||||
@ -1,84 +0,0 @@
|
|||||||
From 9f843b181db3d73e86df140a41975a7645adc071 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Kunkun Jiang <jiangkunkun@huawei.com>
|
|
||||||
Date: Fri, 18 Nov 2022 15:22:27 +0800
|
|
||||||
Subject: [PATCH 10/36] Revert "pci: Add return_page_response pci ops"
|
|
||||||
|
|
||||||
This reverts commit 228345cfa59c764e725e2d3680a4bc3ecb237609.
|
|
||||||
|
|
||||||
Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com>
|
|
||||||
---
|
|
||||||
hw/pci/pci.c | 16 ----------------
|
|
||||||
include/hw/iommu/iommu.h | 8 --------
|
|
||||||
include/hw/pci/pci.h | 4 ----
|
|
||||||
3 files changed, 28 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/hw/pci/pci.c b/hw/pci/pci.c
|
|
||||||
index 0743dc7c42..71076fff48 100644
|
|
||||||
--- a/hw/pci/pci.c
|
|
||||||
+++ b/hw/pci/pci.c
|
|
||||||
@@ -2797,22 +2797,6 @@ int pci_device_set_pasid_table(PCIBus *bus, int32_t devfn,
|
|
||||||
return -ENOENT;
|
|
||||||
}
|
|
||||||
|
|
||||||
-int pci_device_return_page_response(PCIBus *bus, int32_t devfn,
|
|
||||||
- IOMMUPageResponse *resp)
|
|
||||||
-{
|
|
||||||
- PCIDevice *dev;
|
|
||||||
-
|
|
||||||
- if (!bus) {
|
|
||||||
- return -EINVAL;
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
- dev = bus->devices[devfn];
|
|
||||||
- if (dev && dev->pasid_ops && dev->pasid_ops->return_page_response) {
|
|
||||||
- return dev->pasid_ops->return_page_response(bus, devfn, resp);
|
|
||||||
- }
|
|
||||||
- return -ENOENT;
|
|
||||||
-}
|
|
||||||
-
|
|
||||||
static void pci_dev_get_w64(PCIBus *b, PCIDevice *dev, void *opaque)
|
|
||||||
{
|
|
||||||
Range *range = opaque;
|
|
||||||
diff --git a/include/hw/iommu/iommu.h b/include/hw/iommu/iommu.h
|
|
||||||
index 5890f095b1..12092bda7b 100644
|
|
||||||
--- a/include/hw/iommu/iommu.h
|
|
||||||
+++ b/include/hw/iommu/iommu.h
|
|
||||||
@@ -24,13 +24,5 @@ typedef struct IOMMUConfig {
|
|
||||||
};
|
|
||||||
} IOMMUConfig;
|
|
||||||
|
|
||||||
-typedef struct IOMMUPageResponse {
|
|
||||||
- union {
|
|
||||||
-#ifdef __linux__
|
|
||||||
- struct iommu_page_response resp;
|
|
||||||
-#endif
|
|
||||||
- };
|
|
||||||
-} IOMMUPageResponse;
|
|
||||||
-
|
|
||||||
|
|
||||||
#endif /* QEMU_HW_IOMMU_IOMMU_H */
|
|
||||||
diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h
|
|
||||||
index bfe3a6bca7..4cf3dc6b43 100644
|
|
||||||
--- a/include/hw/pci/pci.h
|
|
||||||
+++ b/include/hw/pci/pci.h
|
|
||||||
@@ -268,8 +268,6 @@ typedef struct PCIReqIDCache PCIReqIDCache;
|
|
||||||
|
|
||||||
struct PCIPASIDOps {
|
|
||||||
int (*set_pasid_table)(PCIBus *bus, int32_t devfn, IOMMUConfig *config);
|
|
||||||
- int (*return_page_response)(PCIBus *bus, int32_t devfn,
|
|
||||||
- IOMMUPageResponse *resp);
|
|
||||||
};
|
|
||||||
typedef struct PCIPASIDOps PCIPASIDOps;
|
|
||||||
|
|
||||||
@@ -510,8 +508,6 @@ void pci_setup_iommu(PCIBus *bus, PCIIOMMUFunc fn, void *opaque);
|
|
||||||
void pci_setup_pasid_ops(PCIDevice *dev, PCIPASIDOps *ops);
|
|
||||||
bool pci_device_is_pasid_ops_set(PCIBus *bus, int32_t devfn);
|
|
||||||
int pci_device_set_pasid_table(PCIBus *bus, int32_t devfn, IOMMUConfig *config);
|
|
||||||
-int pci_device_return_page_response(PCIBus *bus, int32_t devfn,
|
|
||||||
- IOMMUPageResponse *resp);
|
|
||||||
|
|
||||||
static inline void
|
|
||||||
pci_set_byte(uint8_t *config, uint8_t val)
|
|
||||||
--
|
|
||||||
2.27.0
|
|
||||||
|
|
||||||
@ -1,104 +0,0 @@
|
|||||||
From 87a125d3a175fd65f921dc7089450e13ce2ac457 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Kunkun Jiang <jiangkunkun@huawei.com>
|
|
||||||
Date: Fri, 18 Nov 2022 15:22:49 +0800
|
|
||||||
Subject: [PATCH 27/36] Revert "pci: introduce PCIPASIDOps to PCIDevice"
|
|
||||||
|
|
||||||
This reverts commit c71485494970e7aa986be2b05bf7e2847017e264.
|
|
||||||
|
|
||||||
Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com>
|
|
||||||
---
|
|
||||||
hw/pci/pci.c | 34 ----------------------------------
|
|
||||||
include/hw/pci/pci.h | 11 -----------
|
|
||||||
2 files changed, 45 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/hw/pci/pci.c b/hw/pci/pci.c
|
|
||||||
index 71076fff48..40e2516d99 100644
|
|
||||||
--- a/hw/pci/pci.c
|
|
||||||
+++ b/hw/pci/pci.c
|
|
||||||
@@ -2763,40 +2763,6 @@ void pci_setup_iommu(PCIBus *bus, PCIIOMMUFunc fn, void *opaque)
|
|
||||||
bus->iommu_opaque = opaque;
|
|
||||||
}
|
|
||||||
|
|
||||||
-void pci_setup_pasid_ops(PCIDevice *dev, PCIPASIDOps *ops)
|
|
||||||
-{
|
|
||||||
- assert(ops && !dev->pasid_ops);
|
|
||||||
- dev->pasid_ops = ops;
|
|
||||||
-}
|
|
||||||
-
|
|
||||||
-bool pci_device_is_pasid_ops_set(PCIBus *bus, int32_t devfn)
|
|
||||||
-{
|
|
||||||
- PCIDevice *dev;
|
|
||||||
-
|
|
||||||
- if (!bus) {
|
|
||||||
- return false;
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
- dev = bus->devices[devfn];
|
|
||||||
- return !!(dev && dev->pasid_ops);
|
|
||||||
-}
|
|
||||||
-
|
|
||||||
-int pci_device_set_pasid_table(PCIBus *bus, int32_t devfn,
|
|
||||||
- IOMMUConfig *config)
|
|
||||||
-{
|
|
||||||
- PCIDevice *dev;
|
|
||||||
-
|
|
||||||
- if (!bus) {
|
|
||||||
- return -EINVAL;
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
- dev = bus->devices[devfn];
|
|
||||||
- if (dev && dev->pasid_ops && dev->pasid_ops->set_pasid_table) {
|
|
||||||
- return dev->pasid_ops->set_pasid_table(bus, devfn, config);
|
|
||||||
- }
|
|
||||||
- return -ENOENT;
|
|
||||||
-}
|
|
||||||
-
|
|
||||||
static void pci_dev_get_w64(PCIBus *b, PCIDevice *dev, void *opaque)
|
|
||||||
{
|
|
||||||
Range *range = opaque;
|
|
||||||
diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h
|
|
||||||
index 4cf3dc6b43..5b36334a28 100644
|
|
||||||
--- a/include/hw/pci/pci.h
|
|
||||||
+++ b/include/hw/pci/pci.h
|
|
||||||
@@ -9,7 +9,6 @@
|
|
||||||
|
|
||||||
#include "hw/pci/pcie.h"
|
|
||||||
#include "qom/object.h"
|
|
||||||
-#include "hw/iommu/iommu.h"
|
|
||||||
|
|
||||||
extern bool pci_available;
|
|
||||||
|
|
||||||
@@ -266,11 +265,6 @@ struct PCIReqIDCache {
|
|
||||||
};
|
|
||||||
typedef struct PCIReqIDCache PCIReqIDCache;
|
|
||||||
|
|
||||||
-struct PCIPASIDOps {
|
|
||||||
- int (*set_pasid_table)(PCIBus *bus, int32_t devfn, IOMMUConfig *config);
|
|
||||||
-};
|
|
||||||
-typedef struct PCIPASIDOps PCIPASIDOps;
|
|
||||||
-
|
|
||||||
struct PCIDevice {
|
|
||||||
DeviceState qdev;
|
|
||||||
bool partially_hotplugged;
|
|
||||||
@@ -367,7 +361,6 @@ struct PCIDevice {
|
|
||||||
/* ID of standby device in net_failover pair */
|
|
||||||
char *failover_pair_id;
|
|
||||||
uint32_t acpi_index;
|
|
||||||
- PCIPASIDOps *pasid_ops;
|
|
||||||
};
|
|
||||||
|
|
||||||
void pci_register_bar(PCIDevice *pci_dev, int region_num,
|
|
||||||
@@ -505,10 +498,6 @@ typedef AddressSpace *(*PCIIOMMUFunc)(PCIBus *, void *, int);
|
|
||||||
AddressSpace *pci_device_iommu_address_space(PCIDevice *dev);
|
|
||||||
void pci_setup_iommu(PCIBus *bus, PCIIOMMUFunc fn, void *opaque);
|
|
||||||
|
|
||||||
-void pci_setup_pasid_ops(PCIDevice *dev, PCIPASIDOps *ops);
|
|
||||||
-bool pci_device_is_pasid_ops_set(PCIBus *bus, int32_t devfn);
|
|
||||||
-int pci_device_set_pasid_table(PCIBus *bus, int32_t devfn, IOMMUConfig *config);
|
|
||||||
-
|
|
||||||
static inline void
|
|
||||||
pci_set_byte(uint8_t *config, uint8_t val)
|
|
||||||
{
|
|
||||||
--
|
|
||||||
2.27.0
|
|
||||||
|
|
||||||
@ -1,133 +0,0 @@
|
|||||||
From 92e9fb334c38cd21652ce8adde9ec01ab4412426 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Jinhua Cao <caojinhua1@hauwei.com>
|
|
||||||
Date: Tue, 15 Feb 2022 15:18:17 +0800
|
|
||||||
Subject: [PATCH] Revert "qmp: add command to query used memslots of vhost-net
|
|
||||||
and vhost-user"
|
|
||||||
|
|
||||||
This reverts commit 1545a60a8b78490c7dc8909b7012bca63dba63cd.
|
|
||||||
|
|
||||||
Signed-off-by: Jinhua Cao <caojinhua1@huawei.com>
|
|
||||||
---
|
|
||||||
hw/virtio/vhost-backend.c | 2 +-
|
|
||||||
hw/virtio/vhost-user.c | 2 +-
|
|
||||||
include/hw/virtio/vhost-backend.h | 2 --
|
|
||||||
monitor/qmp-cmds.c | 12 ------------
|
|
||||||
qapi/net.json | 18 ------------------
|
|
||||||
qapi/pragma.json | 4 +---
|
|
||||||
6 files changed, 3 insertions(+), 37 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/hw/virtio/vhost-backend.c b/hw/virtio/vhost-backend.c
|
|
||||||
index d8e1710758..2acfb750fd 100644
|
|
||||||
--- a/hw/virtio/vhost-backend.c
|
|
||||||
+++ b/hw/virtio/vhost-backend.c
|
|
||||||
@@ -300,7 +300,7 @@ static void vhost_kernel_set_used_memslots(struct vhost_dev *dev)
|
|
||||||
vhost_kernel_used_memslots = dev->mem->nregions;
|
|
||||||
}
|
|
||||||
|
|
||||||
-unsigned int vhost_kernel_get_used_memslots(void)
|
|
||||||
+static unsigned int vhost_kernel_get_used_memslots(void)
|
|
||||||
{
|
|
||||||
return vhost_kernel_used_memslots;
|
|
||||||
}
|
|
||||||
diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c
|
|
||||||
index 8f69a3b850..176cae9244 100644
|
|
||||||
--- a/hw/virtio/vhost-user.c
|
|
||||||
+++ b/hw/virtio/vhost-user.c
|
|
||||||
@@ -2544,7 +2544,7 @@ static void vhost_user_set_used_memslots(struct vhost_dev *dev)
|
|
||||||
vhost_user_used_memslots = counter;
|
|
||||||
}
|
|
||||||
|
|
||||||
-unsigned int vhost_user_get_used_memslots(void)
|
|
||||||
+static unsigned int vhost_user_get_used_memslots(void)
|
|
||||||
{
|
|
||||||
return vhost_user_used_memslots;
|
|
||||||
}
|
|
||||||
diff --git a/include/hw/virtio/vhost-backend.h b/include/hw/virtio/vhost-backend.h
|
|
||||||
index 7bbc658161..a64708f456 100644
|
|
||||||
--- a/include/hw/virtio/vhost-backend.h
|
|
||||||
+++ b/include/hw/virtio/vhost-backend.h
|
|
||||||
@@ -190,6 +190,4 @@ int vhost_backend_handle_iotlb_msg(struct vhost_dev *dev,
|
|
||||||
|
|
||||||
int vhost_user_gpu_set_socket(struct vhost_dev *dev, int fd);
|
|
||||||
|
|
||||||
-unsigned int vhost_kernel_get_used_memslots(void);
|
|
||||||
-unsigned int vhost_user_get_used_memslots(void);
|
|
||||||
#endif /* VHOST_BACKEND_H */
|
|
||||||
diff --git a/monitor/qmp-cmds.c b/monitor/qmp-cmds.c
|
|
||||||
index a138e7dd4b..d71beace6a 100644
|
|
||||||
--- a/monitor/qmp-cmds.c
|
|
||||||
+++ b/monitor/qmp-cmds.c
|
|
||||||
@@ -37,7 +37,6 @@
|
|
||||||
#include "qapi/qapi-commands-machine.h"
|
|
||||||
#include "qapi/qapi-commands-misc.h"
|
|
||||||
#include "qapi/qapi-commands-ui.h"
|
|
||||||
-#include "qapi/qapi-commands-net.h"
|
|
||||||
#include "qapi/type-helpers.h"
|
|
||||||
#include "qapi/qmp/qerror.h"
|
|
||||||
#include "exec/ramlist.h"
|
|
||||||
@@ -45,7 +44,6 @@
|
|
||||||
#include "hw/acpi/acpi_dev_interface.h"
|
|
||||||
#include "hw/intc/intc.h"
|
|
||||||
#include "hw/rdma/rdma.h"
|
|
||||||
-#include "hw/virtio/vhost-backend.h"
|
|
||||||
|
|
||||||
NameInfo *qmp_query_name(Error **errp)
|
|
||||||
{
|
|
||||||
@@ -476,13 +474,3 @@ int64_t qmp_query_rtc_date_diff(Error **errp)
|
|
||||||
{
|
|
||||||
return get_rtc_date_diff();
|
|
||||||
}
|
|
||||||
-
|
|
||||||
-uint32_t qmp_query_vhost_kernel_used_memslots(Error **errp)
|
|
||||||
-{
|
|
||||||
- return vhost_kernel_get_used_memslots();
|
|
||||||
-}
|
|
||||||
-
|
|
||||||
-uint32_t qmp_query_vhost_user_used_memslots(Error **errp)
|
|
||||||
-{
|
|
||||||
- return vhost_user_get_used_memslots();
|
|
||||||
-}
|
|
||||||
diff --git a/qapi/net.json b/qapi/net.json
|
|
||||||
index c9ff849eed..7fab2e7cd8 100644
|
|
||||||
--- a/qapi/net.json
|
|
||||||
+++ b/qapi/net.json
|
|
||||||
@@ -696,21 +696,3 @@
|
|
||||||
##
|
|
||||||
{ 'event': 'FAILOVER_NEGOTIATED',
|
|
||||||
'data': {'device-id': 'str'} }
|
|
||||||
-
|
|
||||||
-##
|
|
||||||
-# @query-vhost-kernel-used-memslots:
|
|
||||||
-#
|
|
||||||
-# Get vhost-kernel nic used memslots
|
|
||||||
-#
|
|
||||||
-# Since: 4.1
|
|
||||||
-##
|
|
||||||
-{ 'command': 'query-vhost-kernel-used-memslots', 'returns': 'uint32' }
|
|
||||||
-
|
|
||||||
-##
|
|
||||||
-# @query-vhost-user-used-memslots:
|
|
||||||
-#
|
|
||||||
-# Get vhost-user nic used memslots
|
|
||||||
-#
|
|
||||||
-# Since: 4.1
|
|
||||||
-##
|
|
||||||
-{ 'command': 'query-vhost-user-used-memslots', 'returns': 'uint32' }
|
|
||||||
diff --git a/qapi/pragma.json b/qapi/pragma.json
|
|
||||||
index d35c897acb..b37f6de445 100644
|
|
||||||
--- a/qapi/pragma.json
|
|
||||||
+++ b/qapi/pragma.json
|
|
||||||
@@ -27,9 +27,7 @@
|
|
||||||
'query-tpm-models',
|
|
||||||
'query-tpm-types',
|
|
||||||
'ringbuf-read',
|
|
||||||
- 'query-rtc-date-diff',
|
|
||||||
- 'query-vhost-user-used-memslots',
|
|
||||||
- 'query-vhost-kernel-used-memslots' ],
|
|
||||||
+ 'query-rtc-date-diff' ],
|
|
||||||
# Externally visible types whose member names may use uppercase
|
|
||||||
'member-name-exceptions': [ # visible in:
|
|
||||||
'ACPISlotType', # query-acpi-ospm-status
|
|
||||||
--
|
|
||||||
2.27.0
|
|
||||||
|
|
||||||
@ -1,28 +0,0 @@
|
|||||||
From 00e2515716eda5426bd999f812add9ff70204fc6 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Kunkun Jiang <jiangkunkun@huawei.com>
|
|
||||||
Date: Fri, 18 Nov 2022 15:23:00 +0800
|
|
||||||
Subject: [PATCH 36/36] Revert "update-linux-headers: Import iommu.h"
|
|
||||||
|
|
||||||
This reverts commit 694acf3c321908d26ce508842b7bd076664ffbc6.
|
|
||||||
|
|
||||||
Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com>
|
|
||||||
---
|
|
||||||
scripts/update-linux-headers.sh | 2 +-
|
|
||||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
|
||||||
|
|
||||||
diff --git a/scripts/update-linux-headers.sh b/scripts/update-linux-headers.sh
|
|
||||||
index acde610733..fea4d6eb65 100755
|
|
||||||
--- a/scripts/update-linux-headers.sh
|
|
||||||
+++ b/scripts/update-linux-headers.sh
|
|
||||||
@@ -144,7 +144,7 @@ done
|
|
||||||
|
|
||||||
rm -rf "$output/linux-headers/linux"
|
|
||||||
mkdir -p "$output/linux-headers/linux"
|
|
||||||
-for header in kvm.h vfio.h vfio_ccw.h vfio_zdev.h vhost.h iommu.h \
|
|
||||||
+for header in kvm.h vfio.h vfio_ccw.h vfio_zdev.h vhost.h \
|
|
||||||
psci.h psp-sev.h userfaultfd.h mman.h; do
|
|
||||||
cp "$tmpdir/include/linux/$header" "$output/linux-headers/linux"
|
|
||||||
done
|
|
||||||
--
|
|
||||||
2.27.0
|
|
||||||
|
|
||||||
@ -1,65 +0,0 @@
|
|||||||
From 92c1c6d689d9f501a3f242b085cbbcb22ee931b4 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Kunkun Jiang <jiangkunkun@huawei.com>
|
|
||||||
Date: Fri, 18 Nov 2022 15:22:18 +0800
|
|
||||||
Subject: [PATCH 04/36] Revert "vfio: Add
|
|
||||||
vfio_prereg_listener_global_log_start/stop in nested stage"
|
|
||||||
|
|
||||||
This reverts commit 287c63ab540533f1f9642e753c091caa7e6e2511.
|
|
||||||
|
|
||||||
Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com>
|
|
||||||
---
|
|
||||||
hw/vfio/common.c | 24 ------------------------
|
|
||||||
1 file changed, 24 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/hw/vfio/common.c b/hw/vfio/common.c
|
|
||||||
index 65f3979492..20c820aa74 100644
|
|
||||||
--- a/hw/vfio/common.c
|
|
||||||
+++ b/hw/vfio/common.c
|
|
||||||
@@ -1501,17 +1501,6 @@ static void vfio_listener_log_global_start(MemoryListener *listener)
|
|
||||||
{
|
|
||||||
VFIOContainer *container = container_of(listener, VFIOContainer, listener);
|
|
||||||
|
|
||||||
- /* For nested mode, vfio_prereg_listener is used to start dirty tracking */
|
|
||||||
- if (container->iommu_type != VFIO_TYPE1_NESTING_IOMMU) {
|
|
||||||
- vfio_set_dirty_page_tracking(container, true);
|
|
||||||
- }
|
|
||||||
-}
|
|
||||||
-
|
|
||||||
-static void vfio_prereg_listener_log_global_start(MemoryListener *listener)
|
|
||||||
-{
|
|
||||||
- VFIOContainer *container =
|
|
||||||
- container_of(listener, VFIOContainer, prereg_listener);
|
|
||||||
-
|
|
||||||
vfio_set_dirty_page_tracking(container, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1519,17 +1508,6 @@ static void vfio_listener_log_global_stop(MemoryListener *listener)
|
|
||||||
{
|
|
||||||
VFIOContainer *container = container_of(listener, VFIOContainer, listener);
|
|
||||||
|
|
||||||
- /* For nested mode, vfio_prereg_listener is used to stop dirty tracking */
|
|
||||||
- if (container->iommu_type != VFIO_TYPE1_NESTING_IOMMU) {
|
|
||||||
- vfio_set_dirty_page_tracking(container, false);
|
|
||||||
- }
|
|
||||||
-}
|
|
||||||
-
|
|
||||||
-static void vfio_prereg_listener_log_global_stop(MemoryListener *listener)
|
|
||||||
-{
|
|
||||||
- VFIOContainer *container =
|
|
||||||
- container_of(listener, VFIOContainer, prereg_listener);
|
|
||||||
-
|
|
||||||
vfio_set_dirty_page_tracking(container, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1944,8 +1922,6 @@ static const MemoryListener vfio_memory_listener = {
|
|
||||||
static MemoryListener vfio_memory_prereg_listener = {
|
|
||||||
.region_add = vfio_prereg_listener_region_add,
|
|
||||||
.region_del = vfio_prereg_listener_region_del,
|
|
||||||
- .log_global_start = vfio_prereg_listener_log_global_start,
|
|
||||||
- .log_global_stop = vfio_prereg_listener_log_global_stop,
|
|
||||||
.log_sync = vfio_prereg_listener_log_sync,
|
|
||||||
.log_clear = vfio_prereg_listener_log_clear,
|
|
||||||
};
|
|
||||||
--
|
|
||||||
2.27.0
|
|
||||||
|
|
||||||
@ -1,81 +0,0 @@
|
|||||||
From 609b216873bfa9377f624dabcf709930e1722ca7 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Kunkun Jiang <jiangkunkun@huawei.com>
|
|
||||||
Date: Fri, 18 Nov 2022 15:22:20 +0800
|
|
||||||
Subject: [PATCH 05/36] Revert "vfio: Add vfio_prereg_listener_log_clear to
|
|
||||||
re-enable mark dirty pages"
|
|
||||||
|
|
||||||
This reverts commit 7086df6d90cd698a3e20cf4cf6e9a834f168cd8f.
|
|
||||||
|
|
||||||
Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com>
|
|
||||||
---
|
|
||||||
hw/vfio/common.c | 40 +---------------------------------------
|
|
||||||
1 file changed, 1 insertion(+), 39 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/hw/vfio/common.c b/hw/vfio/common.c
|
|
||||||
index 20c820aa74..2506cd57ee 100644
|
|
||||||
--- a/hw/vfio/common.c
|
|
||||||
+++ b/hw/vfio/common.c
|
|
||||||
@@ -1857,43 +1857,6 @@ static int vfio_physical_log_clear(VFIOContainer *container,
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
-static void vfio_prereg_listener_log_clear(MemoryListener *listener,
|
|
||||||
- MemoryRegionSection *section)
|
|
||||||
-{
|
|
||||||
- VFIOContainer *container =
|
|
||||||
- container_of(listener, VFIOContainer, prereg_listener);
|
|
||||||
-
|
|
||||||
- if (!memory_region_is_ram(section->mr)) {
|
|
||||||
- return;
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
- vfio_physical_log_clear(container, section);
|
|
||||||
-}
|
|
||||||
-
|
|
||||||
-static int vfio_clear_dirty_bitmap(VFIOContainer *container,
|
|
||||||
- MemoryRegionSection *section)
|
|
||||||
-{
|
|
||||||
- if (memory_region_is_iommu(section->mr)) {
|
|
||||||
- /*
|
|
||||||
- * In nested mode, stage 2 (gpa->hpa) and stage 1 (giova->gpa) are
|
|
||||||
- * set up separately. It is inappropriate to pass 'giova' to kernel
|
|
||||||
- * to get dirty pages. We only need to focus on stage 2 mapping when
|
|
||||||
- * marking dirty pages.
|
|
||||||
- */
|
|
||||||
- if (container->iommu_type == VFIO_TYPE1_NESTING_IOMMU) {
|
|
||||||
- return 0;
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
- /*
|
|
||||||
- * TODO: x86. With the log_clear() interface added, x86 may inplement
|
|
||||||
- * its own method.
|
|
||||||
- */
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
- /* Here we assume that memory_region_is_ram(section->mr) == true */
|
|
||||||
- return vfio_physical_log_clear(container, section);
|
|
||||||
-}
|
|
||||||
-
|
|
||||||
static void vfio_listener_log_clear(MemoryListener *listener,
|
|
||||||
MemoryRegionSection *section)
|
|
||||||
{
|
|
||||||
@@ -1905,7 +1868,7 @@ static void vfio_listener_log_clear(MemoryListener *listener,
|
|
||||||
}
|
|
||||||
|
|
||||||
if (vfio_devices_all_dirty_tracking(container)) {
|
|
||||||
- vfio_clear_dirty_bitmap(container, section);
|
|
||||||
+ vfio_physical_log_clear(container, section);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1923,7 +1886,6 @@ static MemoryListener vfio_memory_prereg_listener = {
|
|
||||||
.region_add = vfio_prereg_listener_region_add,
|
|
||||||
.region_del = vfio_prereg_listener_region_del,
|
|
||||||
.log_sync = vfio_prereg_listener_log_sync,
|
|
||||||
- .log_clear = vfio_prereg_listener_log_clear,
|
|
||||||
};
|
|
||||||
|
|
||||||
static void vfio_listener_release(VFIOContainer *container)
|
|
||||||
--
|
|
||||||
2.27.0
|
|
||||||
|
|
||||||
@ -1,68 +0,0 @@
|
|||||||
From 13253899d93b287a7e8d78bdff48978f633eb279 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Kunkun Jiang <jiangkunkun@huawei.com>
|
|
||||||
Date: Fri, 18 Nov 2022 15:22:22 +0800
|
|
||||||
Subject: [PATCH 06/36] Revert "vfio: Add vfio_prereg_listener_log_sync in
|
|
||||||
nested stage"
|
|
||||||
|
|
||||||
This reverts commit f4523389bf57593484308124e06d67855bb79315.
|
|
||||||
|
|
||||||
Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com>
|
|
||||||
---
|
|
||||||
hw/vfio/common.c | 27 ---------------------------
|
|
||||||
1 file changed, 27 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/hw/vfio/common.c b/hw/vfio/common.c
|
|
||||||
index 2506cd57ee..6136b1ef61 100644
|
|
||||||
--- a/hw/vfio/common.c
|
|
||||||
+++ b/hw/vfio/common.c
|
|
||||||
@@ -1579,22 +1579,6 @@ static int vfio_dma_sync_ram_section_dirty_bitmap(VFIOContainer *container,
|
|
||||||
int128_get64(section->size), ram_addr);
|
|
||||||
}
|
|
||||||
|
|
||||||
-static void vfio_prereg_listener_log_sync(MemoryListener *listener,
|
|
||||||
- MemoryRegionSection *section)
|
|
||||||
-{
|
|
||||||
- VFIOContainer *container =
|
|
||||||
- container_of(listener, VFIOContainer, prereg_listener);
|
|
||||||
-
|
|
||||||
- if (!memory_region_is_ram(section->mr) ||
|
|
||||||
- !container->dirty_pages_supported) {
|
|
||||||
- return;
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
- if (vfio_devices_all_dirty_tracking(container)) {
|
|
||||||
- vfio_dma_sync_ram_section_dirty_bitmap(container, section);
|
|
||||||
- }
|
|
||||||
-}
|
|
||||||
-
|
|
||||||
typedef struct {
|
|
||||||
IOMMUNotifier n;
|
|
||||||
VFIOGuestIOMMU *giommu;
|
|
||||||
@@ -1682,16 +1666,6 @@ static int vfio_sync_dirty_bitmap(VFIOContainer *container,
|
|
||||||
if (memory_region_is_iommu(section->mr)) {
|
|
||||||
VFIOGuestIOMMU *giommu;
|
|
||||||
|
|
||||||
- /*
|
|
||||||
- * In nested mode, stage 2 (gpa->hpa) and stage 1 (giova->gpa) are
|
|
||||||
- * set up separately. It is inappropriate to pass 'giova' to kernel
|
|
||||||
- * to get dirty pages. We only need to focus on stage 2 mapping when
|
|
||||||
- * marking dirty pages.
|
|
||||||
- */
|
|
||||||
- if (container->iommu_type == VFIO_TYPE1_NESTING_IOMMU) {
|
|
||||||
- return 0;
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
QLIST_FOREACH(giommu, &container->giommu_list, giommu_next) {
|
|
||||||
if (MEMORY_REGION(giommu->iommu) == section->mr &&
|
|
||||||
giommu->n.start == section->offset_within_region) {
|
|
||||||
@@ -1885,7 +1859,6 @@ static const MemoryListener vfio_memory_listener = {
|
|
||||||
static MemoryListener vfio_memory_prereg_listener = {
|
|
||||||
.region_add = vfio_prereg_listener_region_add,
|
|
||||||
.region_del = vfio_prereg_listener_region_del,
|
|
||||||
- .log_sync = vfio_prereg_listener_log_sync,
|
|
||||||
};
|
|
||||||
|
|
||||||
static void vfio_listener_release(VFIOContainer *container)
|
|
||||||
--
|
|
||||||
2.27.0
|
|
||||||
|
|
||||||
@ -1,97 +0,0 @@
|
|||||||
From bac64f79264fd95b349004dd20b4ef7e9944fcb7 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Kunkun Jiang <jiangkunkun@huawei.com>
|
|
||||||
Date: Fri, 18 Nov 2022 15:22:47 +0800
|
|
||||||
Subject: [PATCH 26/36] Revert "vfio: Force nested if iommu requires it"
|
|
||||||
|
|
||||||
This reverts commit e7eef5af743a53f0415267ebe9bba2e5f0e05816.
|
|
||||||
|
|
||||||
Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com>
|
|
||||||
---
|
|
||||||
hw/vfio/common.c | 36 ++++++++----------------------------
|
|
||||||
1 file changed, 8 insertions(+), 28 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/hw/vfio/common.c b/hw/vfio/common.c
|
|
||||||
index d7533637c9..6cb91e7ffd 100644
|
|
||||||
--- a/hw/vfio/common.c
|
|
||||||
+++ b/hw/vfio/common.c
|
|
||||||
@@ -2045,38 +2045,27 @@ static void vfio_put_address_space(VFIOAddressSpace *space)
|
|
||||||
* vfio_get_iommu_type - selects the richest iommu_type (v2 first)
|
|
||||||
*/
|
|
||||||
static int vfio_get_iommu_type(VFIOContainer *container,
|
|
||||||
- bool want_nested,
|
|
||||||
Error **errp)
|
|
||||||
{
|
|
||||||
- int iommu_types[] = { VFIO_TYPE1_NESTING_IOMMU,
|
|
||||||
- VFIO_TYPE1v2_IOMMU, VFIO_TYPE1_IOMMU,
|
|
||||||
+ int iommu_types[] = { VFIO_TYPE1v2_IOMMU, VFIO_TYPE1_IOMMU,
|
|
||||||
VFIO_SPAPR_TCE_v2_IOMMU, VFIO_SPAPR_TCE_IOMMU };
|
|
||||||
- int i, ret = -EINVAL;
|
|
||||||
+ int i;
|
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_SIZE(iommu_types); i++) {
|
|
||||||
if (ioctl(container->fd, VFIO_CHECK_EXTENSION, iommu_types[i])) {
|
|
||||||
- if (iommu_types[i] == VFIO_TYPE1_NESTING_IOMMU && !want_nested) {
|
|
||||||
- continue;
|
|
||||||
- }
|
|
||||||
- ret = iommu_types[i];
|
|
||||||
- break;
|
|
||||||
+ return iommu_types[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
- if (ret < 0) {
|
|
||||||
- error_setg(errp, "No available IOMMU models");
|
|
||||||
- } else if (want_nested && ret != VFIO_TYPE1_NESTING_IOMMU) {
|
|
||||||
- error_setg(errp, "Nested mode requested but not supported");
|
|
||||||
- ret = -EINVAL;
|
|
||||||
- }
|
|
||||||
- return ret;
|
|
||||||
+ error_setg(errp, "No available IOMMU models");
|
|
||||||
+ return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int vfio_init_container(VFIOContainer *container, int group_fd,
|
|
||||||
- bool want_nested, Error **errp)
|
|
||||||
+ Error **errp)
|
|
||||||
{
|
|
||||||
int iommu_type, dirty_log_manual_clear, ret;
|
|
||||||
|
|
||||||
- iommu_type = vfio_get_iommu_type(container, want_nested, errp);
|
|
||||||
+ iommu_type = vfio_get_iommu_type(container, errp);
|
|
||||||
if (iommu_type < 0) {
|
|
||||||
return iommu_type;
|
|
||||||
}
|
|
||||||
@@ -2188,14 +2177,6 @@ static int vfio_connect_container(VFIOGroup *group, AddressSpace *as,
|
|
||||||
VFIOContainer *container;
|
|
||||||
int ret, fd;
|
|
||||||
VFIOAddressSpace *space;
|
|
||||||
- IOMMUMemoryRegion *iommu_mr;
|
|
||||||
- bool nested = false;
|
|
||||||
-
|
|
||||||
- if (memory_region_is_iommu(as->root)) {
|
|
||||||
- iommu_mr = IOMMU_MEMORY_REGION(as->root);
|
|
||||||
- memory_region_iommu_get_attr(iommu_mr, IOMMU_ATTR_VFIO_NESTED,
|
|
||||||
- (void *)&nested);
|
|
||||||
- }
|
|
||||||
|
|
||||||
space = vfio_get_address_space(as);
|
|
||||||
|
|
||||||
@@ -2276,7 +2257,7 @@ static int vfio_connect_container(VFIOGroup *group, AddressSpace *as,
|
|
||||||
QLIST_INIT(&container->vrdl_list);
|
|
||||||
QLIST_INIT(&container->dma_list);
|
|
||||||
|
|
||||||
- ret = vfio_init_container(container, group->fd, nested, errp);
|
|
||||||
+ ret = vfio_init_container(container, group->fd, errp);
|
|
||||||
if (ret) {
|
|
||||||
goto free_container_exit;
|
|
||||||
}
|
|
||||||
@@ -2288,7 +2269,6 @@ static int vfio_connect_container(VFIOGroup *group, AddressSpace *as,
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (container->iommu_type) {
|
|
||||||
- case VFIO_TYPE1_NESTING_IOMMU:
|
|
||||||
case VFIO_TYPE1v2_IOMMU:
|
|
||||||
case VFIO_TYPE1_IOMMU:
|
|
||||||
{
|
|
||||||
--
|
|
||||||
2.27.0
|
|
||||||
|
|
||||||
@ -1,177 +0,0 @@
|
|||||||
From 1ab4bff7e5d82a16a0d004fd964819d092325776 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Kunkun Jiang <jiangkunkun@huawei.com>
|
|
||||||
Date: Fri, 18 Nov 2022 15:22:41 +0800
|
|
||||||
Subject: [PATCH 21/36] Revert "vfio: Helper to get IRQ info including
|
|
||||||
capabilities"
|
|
||||||
|
|
||||||
This reverts commit a4336765c99a876743c0ead89997ad6f97d7b442.
|
|
||||||
|
|
||||||
Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com>
|
|
||||||
---
|
|
||||||
hw/vfio/common.c | 97 -----------------------------------
|
|
||||||
hw/vfio/trace-events | 1 -
|
|
||||||
include/hw/vfio/vfio-common.h | 7 ---
|
|
||||||
3 files changed, 105 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/hw/vfio/common.c b/hw/vfio/common.c
|
|
||||||
index d05a485808..1f78af121d 100644
|
|
||||||
--- a/hw/vfio/common.c
|
|
||||||
+++ b/hw/vfio/common.c
|
|
||||||
@@ -1919,25 +1919,6 @@ bool vfio_get_info_dma_avail(struct vfio_iommu_type1_info *info,
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
-struct vfio_info_cap_header *
|
|
||||||
-vfio_get_irq_info_cap(struct vfio_irq_info *info, uint16_t id)
|
|
||||||
-{
|
|
||||||
- struct vfio_info_cap_header *hdr;
|
|
||||||
- void *ptr = info;
|
|
||||||
-
|
|
||||||
- if (!(info->flags & VFIO_IRQ_INFO_FLAG_CAPS)) {
|
|
||||||
- return NULL;
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
- for (hdr = ptr + info->cap_offset; hdr != ptr; hdr = ptr + hdr->next) {
|
|
||||||
- if (hdr->id == id) {
|
|
||||||
- return hdr;
|
|
||||||
- }
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
- return NULL;
|
|
||||||
-}
|
|
||||||
-
|
|
||||||
static int vfio_setup_region_sparse_mmaps(VFIORegion *region,
|
|
||||||
struct vfio_region_info *info)
|
|
||||||
{
|
|
||||||
@@ -2906,33 +2887,6 @@ retry:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
-int vfio_get_irq_info(VFIODevice *vbasedev, int index,
|
|
||||||
- struct vfio_irq_info **info)
|
|
||||||
-{
|
|
||||||
- size_t argsz = sizeof(struct vfio_irq_info);
|
|
||||||
-
|
|
||||||
- *info = g_malloc0(argsz);
|
|
||||||
-
|
|
||||||
- (*info)->index = index;
|
|
||||||
-retry:
|
|
||||||
- (*info)->argsz = argsz;
|
|
||||||
-
|
|
||||||
- if (ioctl(vbasedev->fd, VFIO_DEVICE_GET_IRQ_INFO, *info)) {
|
|
||||||
- g_free(*info);
|
|
||||||
- *info = NULL;
|
|
||||||
- return -errno;
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
- if ((*info)->argsz > argsz) {
|
|
||||||
- argsz = (*info)->argsz;
|
|
||||||
- *info = g_realloc(*info, argsz);
|
|
||||||
-
|
|
||||||
- goto retry;
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
- return 0;
|
|
||||||
-}
|
|
||||||
-
|
|
||||||
int vfio_get_dev_region_info(VFIODevice *vbasedev, uint32_t type,
|
|
||||||
uint32_t subtype, struct vfio_region_info **info)
|
|
||||||
{
|
|
||||||
@@ -2968,42 +2922,6 @@ int vfio_get_dev_region_info(VFIODevice *vbasedev, uint32_t type,
|
|
||||||
return -ENODEV;
|
|
||||||
}
|
|
||||||
|
|
||||||
-int vfio_get_dev_irq_info(VFIODevice *vbasedev, uint32_t type,
|
|
||||||
- uint32_t subtype, struct vfio_irq_info **info)
|
|
||||||
-{
|
|
||||||
- int i;
|
|
||||||
-
|
|
||||||
- for (i = 0; i < vbasedev->num_irqs; i++) {
|
|
||||||
- struct vfio_info_cap_header *hdr;
|
|
||||||
- struct vfio_irq_info_cap_type *cap_type;
|
|
||||||
-
|
|
||||||
- if (vfio_get_irq_info(vbasedev, i, info)) {
|
|
||||||
- continue;
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
- hdr = vfio_get_irq_info_cap(*info, VFIO_IRQ_INFO_CAP_TYPE);
|
|
||||||
- if (!hdr) {
|
|
||||||
- g_free(*info);
|
|
||||||
- continue;
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
- cap_type = container_of(hdr, struct vfio_irq_info_cap_type, header);
|
|
||||||
-
|
|
||||||
- trace_vfio_get_dev_irq(vbasedev->name, i,
|
|
||||||
- cap_type->type, cap_type->subtype);
|
|
||||||
-
|
|
||||||
- if (cap_type->type == type && cap_type->subtype == subtype) {
|
|
||||||
- return 0;
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
- g_free(*info);
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
- *info = NULL;
|
|
||||||
- return -ENODEV;
|
|
||||||
-}
|
|
||||||
-
|
|
||||||
-
|
|
||||||
bool vfio_has_region_cap(VFIODevice *vbasedev, int region, uint16_t cap_type)
|
|
||||||
{
|
|
||||||
struct vfio_region_info *info = NULL;
|
|
||||||
@@ -3019,21 +2937,6 @@ bool vfio_has_region_cap(VFIODevice *vbasedev, int region, uint16_t cap_type)
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
-bool vfio_has_irq_cap(VFIODevice *vbasedev, int region, uint16_t cap_type)
|
|
||||||
-{
|
|
||||||
- struct vfio_region_info *info = NULL;
|
|
||||||
- bool ret = false;
|
|
||||||
-
|
|
||||||
- if (!vfio_get_region_info(vbasedev, region, &info)) {
|
|
||||||
- if (vfio_get_region_info_cap(info, cap_type)) {
|
|
||||||
- ret = true;
|
|
||||||
- }
|
|
||||||
- g_free(info);
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
- return ret;
|
|
||||||
-}
|
|
||||||
-
|
|
||||||
/*
|
|
||||||
* Interfaces for IBM EEH (Enhanced Error Handling)
|
|
||||||
*/
|
|
||||||
diff --git a/hw/vfio/trace-events b/hw/vfio/trace-events
|
|
||||||
index f5fe201ab5..35bd415d6d 100644
|
|
||||||
--- a/hw/vfio/trace-events
|
|
||||||
+++ b/hw/vfio/trace-events
|
|
||||||
@@ -117,7 +117,6 @@ vfio_region_unmap(const char *name, unsigned long offset, unsigned long end) "Re
|
|
||||||
vfio_region_sparse_mmap_header(const char *name, int index, int nr_areas) "Device %s region %d: %d sparse mmap entries"
|
|
||||||
vfio_region_sparse_mmap_entry(int i, unsigned long start, unsigned long end) "sparse entry %d [0x%lx - 0x%lx]"
|
|
||||||
vfio_get_dev_region(const char *name, int index, uint32_t type, uint32_t subtype) "%s index %d, %08x/%0x8"
|
|
||||||
-vfio_get_dev_irq(const char *name, int index, uint32_t type, uint32_t subtype) "%s index %d, %08x/%0x8"
|
|
||||||
vfio_dma_unmap_overflow_workaround(void) ""
|
|
||||||
vfio_iommu_addr_inv_iotlb(int asid, uint64_t addr, uint64_t size, uint64_t nb_granules, bool leaf) "nested IOTLB invalidate asid=%d, addr=0x%"PRIx64" granule_size=0x%"PRIx64" nb_granules=0x%"PRIx64" leaf=%d"
|
|
||||||
vfio_iommu_asid_inv_iotlb(int asid) "nested IOTLB invalidate asid=%d"
|
|
||||||
diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h
|
|
||||||
index 7fdca26fa0..a838a939e4 100644
|
|
||||||
--- a/include/hw/vfio/vfio-common.h
|
|
||||||
+++ b/include/hw/vfio/vfio-common.h
|
|
||||||
@@ -254,13 +254,6 @@ bool vfio_get_info_dma_avail(struct vfio_iommu_type1_info *info,
|
|
||||||
unsigned int *avail);
|
|
||||||
struct vfio_info_cap_header *
|
|
||||||
vfio_get_device_info_cap(struct vfio_device_info *info, uint16_t id);
|
|
||||||
-int vfio_get_irq_info(VFIODevice *vbasedev, int index,
|
|
||||||
- struct vfio_irq_info **info);
|
|
||||||
-int vfio_get_dev_irq_info(VFIODevice *vbasedev, uint32_t type,
|
|
||||||
- uint32_t subtype, struct vfio_irq_info **info);
|
|
||||||
-bool vfio_has_irq_cap(VFIODevice *vbasedev, int irq, uint16_t cap_type);
|
|
||||||
-struct vfio_info_cap_header *
|
|
||||||
-vfio_get_irq_info_cap(struct vfio_irq_info *info, uint16_t id);
|
|
||||||
#endif
|
|
||||||
extern const MemoryListener vfio_prereg_listener;
|
|
||||||
|
|
||||||
--
|
|
||||||
2.27.0
|
|
||||||
|
|
||||||
@ -1,277 +0,0 @@
|
|||||||
From e73a30ce20cf0686e7a08e061f8afa5c8c385361 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Kunkun Jiang <jiangkunkun@huawei.com>
|
|
||||||
Date: Fri, 18 Nov 2022 15:22:45 +0800
|
|
||||||
Subject: [PATCH 24/36] Revert "vfio: Introduce helpers to DMA map/unmap a RAM
|
|
||||||
section"
|
|
||||||
|
|
||||||
This reverts commit dab969657d8ff8b175856f91b035b74849cf69ba.
|
|
||||||
|
|
||||||
Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com>
|
|
||||||
---
|
|
||||||
hw/vfio/common.c | 206 ++++++++++++++++++-------------------------
|
|
||||||
hw/vfio/trace-events | 4 +-
|
|
||||||
2 files changed, 87 insertions(+), 123 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/hw/vfio/common.c b/hw/vfio/common.c
|
|
||||||
index b3dc090840..d358789f19 100644
|
|
||||||
--- a/hw/vfio/common.c
|
|
||||||
+++ b/hw/vfio/common.c
|
|
||||||
@@ -922,130 +922,13 @@ hostwin_from_range(VFIOContainer *container, hwaddr iova, hwaddr end)
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
-static int vfio_dma_map_ram_section(VFIOContainer *container,
|
|
||||||
- MemoryRegionSection *section, Error **err)
|
|
||||||
-{
|
|
||||||
- VFIOHostDMAWindow *hostwin;
|
|
||||||
- Int128 llend, llsize;
|
|
||||||
- hwaddr iova, end;
|
|
||||||
- void *vaddr;
|
|
||||||
- int ret;
|
|
||||||
-
|
|
||||||
- assert(memory_region_is_ram(section->mr));
|
|
||||||
-
|
|
||||||
- iova = TARGET_PAGE_ALIGN(section->offset_within_address_space);
|
|
||||||
- llend = int128_make64(section->offset_within_address_space);
|
|
||||||
- llend = int128_add(llend, section->size);
|
|
||||||
- llend = int128_and(llend, int128_exts64(TARGET_PAGE_MASK));
|
|
||||||
- end = int128_get64(int128_sub(llend, int128_one()));
|
|
||||||
-
|
|
||||||
- vaddr = memory_region_get_ram_ptr(section->mr) +
|
|
||||||
- section->offset_within_region +
|
|
||||||
- (iova - section->offset_within_address_space);
|
|
||||||
-
|
|
||||||
- hostwin = hostwin_from_range(container, iova, end);
|
|
||||||
- if (!hostwin) {
|
|
||||||
- error_setg(err, "Container %p can't map guest IOVA region"
|
|
||||||
- " 0x%"HWADDR_PRIx"..0x%"HWADDR_PRIx, container, iova, end);
|
|
||||||
- return -EFAULT;
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
- trace_vfio_dma_map_ram(iova, end, vaddr);
|
|
||||||
-
|
|
||||||
- llsize = int128_sub(llend, int128_make64(iova));
|
|
||||||
-
|
|
||||||
- if (memory_region_is_ram_device(section->mr)) {
|
|
||||||
- hwaddr pgmask = (1ULL << ctz64(hostwin->iova_pgsizes)) - 1;
|
|
||||||
-
|
|
||||||
- if ((iova & pgmask) || (int128_get64(llsize) & pgmask)) {
|
|
||||||
- trace_vfio_listener_region_add_no_dma_map(
|
|
||||||
- memory_region_name(section->mr),
|
|
||||||
- section->offset_within_address_space,
|
|
||||||
- int128_getlo(section->size),
|
|
||||||
- pgmask + 1);
|
|
||||||
- return 0;
|
|
||||||
- }
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
- ret = vfio_dma_map(container, iova, int128_get64(llsize),
|
|
||||||
- vaddr, section->readonly);
|
|
||||||
- if (ret) {
|
|
||||||
- error_setg(err, "vfio_dma_map(%p, 0x%"HWADDR_PRIx", "
|
|
||||||
- "0x%"HWADDR_PRIx", %p) = %d (%m)",
|
|
||||||
- container, iova, int128_get64(llsize), vaddr, ret);
|
|
||||||
- if (memory_region_is_ram_device(section->mr)) {
|
|
||||||
- /* Allow unexpected mappings not to be fatal for RAM devices */
|
|
||||||
- error_report_err(*err);
|
|
||||||
- return 0;
|
|
||||||
- }
|
|
||||||
- return ret;
|
|
||||||
- }
|
|
||||||
- return 0;
|
|
||||||
-}
|
|
||||||
-
|
|
||||||
-static void vfio_dma_unmap_ram_section(VFIOContainer *container,
|
|
||||||
- MemoryRegionSection *section)
|
|
||||||
-{
|
|
||||||
- Int128 llend, llsize;
|
|
||||||
- hwaddr iova, end;
|
|
||||||
- bool try_unmap = true;
|
|
||||||
- int ret;
|
|
||||||
-
|
|
||||||
- iova = REAL_HOST_PAGE_ALIGN(section->offset_within_address_space);
|
|
||||||
- llend = int128_make64(section->offset_within_address_space);
|
|
||||||
- llend = int128_add(llend, section->size);
|
|
||||||
- llend = int128_and(llend, int128_exts64(qemu_real_host_page_mask));
|
|
||||||
-
|
|
||||||
- if (int128_ge(int128_make64(iova), llend)) {
|
|
||||||
- return;
|
|
||||||
- }
|
|
||||||
- end = int128_get64(int128_sub(llend, int128_one()));
|
|
||||||
-
|
|
||||||
- llsize = int128_sub(llend, int128_make64(iova));
|
|
||||||
-
|
|
||||||
- trace_vfio_dma_unmap_ram(iova, end);
|
|
||||||
-
|
|
||||||
- if (memory_region_is_ram_device(section->mr)) {
|
|
||||||
- hwaddr pgmask;
|
|
||||||
- VFIOHostDMAWindow *hostwin = hostwin_from_range(container, iova, end);
|
|
||||||
-
|
|
||||||
- assert(hostwin); /* or region_add() would have failed */
|
|
||||||
-
|
|
||||||
- pgmask = (1ULL << ctz64(hostwin->iova_pgsizes)) - 1;
|
|
||||||
- try_unmap = !((iova & pgmask) || (int128_get64(llsize) & pgmask));
|
|
||||||
- } else if (memory_region_has_ram_discard_manager(section->mr)) {
|
|
||||||
- vfio_unregister_ram_discard_listener(container, section);
|
|
||||||
- /* Unregistering will trigger an unmap. */
|
|
||||||
- try_unmap = false;
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
- if (try_unmap) {
|
|
||||||
- if (int128_eq(llsize, int128_2_64())) {
|
|
||||||
- /* The unmap ioctl doesn't accept a full 64-bit span. */
|
|
||||||
- llsize = int128_rshift(llsize, 1);
|
|
||||||
- ret = vfio_dma_unmap(container, iova, int128_get64(llsize), NULL);
|
|
||||||
- if (ret) {
|
|
||||||
- error_report("vfio_dma_unmap(%p, 0x%"HWADDR_PRIx", "
|
|
||||||
- "0x%"HWADDR_PRIx") = %d (%m)",
|
|
||||||
- container, iova, int128_get64(llsize), ret);
|
|
||||||
- }
|
|
||||||
- iova += int128_get64(llsize);
|
|
||||||
- }
|
|
||||||
- ret = vfio_dma_unmap(container, iova, int128_get64(llsize), NULL);
|
|
||||||
- if (ret) {
|
|
||||||
- error_report("vfio_dma_unmap(%p, 0x%"HWADDR_PRIx", "
|
|
||||||
- "0x%"HWADDR_PRIx") = %d (%m)",
|
|
||||||
- container, iova, int128_get64(llsize), ret);
|
|
||||||
- }
|
|
||||||
- }
|
|
||||||
-}
|
|
||||||
-
|
|
||||||
static void vfio_listener_region_add(MemoryListener *listener,
|
|
||||||
MemoryRegionSection *section)
|
|
||||||
{
|
|
||||||
VFIOContainer *container = container_of(listener, VFIOContainer, listener);
|
|
||||||
hwaddr iova, end;
|
|
||||||
- Int128 llend;
|
|
||||||
+ Int128 llend, llsize;
|
|
||||||
+ void *vaddr;
|
|
||||||
int ret;
|
|
||||||
VFIOHostDMAWindow *hostwin;
|
|
||||||
Error *err = NULL;
|
|
||||||
@@ -1209,7 +1092,38 @@ static void vfio_listener_region_add(MemoryListener *listener,
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
- if (vfio_dma_map_ram_section(container, section, &err)) {
|
|
||||||
+ vaddr = memory_region_get_ram_ptr(section->mr) +
|
|
||||||
+ section->offset_within_region +
|
|
||||||
+ (iova - section->offset_within_address_space);
|
|
||||||
+
|
|
||||||
+ trace_vfio_listener_region_add_ram(iova, end, vaddr);
|
|
||||||
+
|
|
||||||
+ llsize = int128_sub(llend, int128_make64(iova));
|
|
||||||
+
|
|
||||||
+ if (memory_region_is_ram_device(section->mr)) {
|
|
||||||
+ hwaddr pgmask = (1ULL << ctz64(hostwin->iova_pgsizes)) - 1;
|
|
||||||
+
|
|
||||||
+ if ((iova & pgmask) || (int128_get64(llsize) & pgmask)) {
|
|
||||||
+ trace_vfio_listener_region_add_no_dma_map(
|
|
||||||
+ memory_region_name(section->mr),
|
|
||||||
+ section->offset_within_address_space,
|
|
||||||
+ int128_getlo(section->size),
|
|
||||||
+ pgmask + 1);
|
|
||||||
+ return;
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ ret = vfio_dma_map(container, iova, int128_get64(llsize),
|
|
||||||
+ vaddr, section->readonly);
|
|
||||||
+ if (ret) {
|
|
||||||
+ error_setg(&err, "vfio_dma_map(%p, 0x%"HWADDR_PRIx", "
|
|
||||||
+ "0x%"HWADDR_PRIx", %p) = %d (%m)",
|
|
||||||
+ container, iova, int128_get64(llsize), vaddr, ret);
|
|
||||||
+ if (memory_region_is_ram_device(section->mr)) {
|
|
||||||
+ /* Allow unexpected mappings not to be fatal for RAM devices */
|
|
||||||
+ error_report_err(err);
|
|
||||||
+ return;
|
|
||||||
+ }
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1243,6 +1157,10 @@ static void vfio_listener_region_del(MemoryListener *listener,
|
|
||||||
MemoryRegionSection *section)
|
|
||||||
{
|
|
||||||
VFIOContainer *container = container_of(listener, VFIOContainer, listener);
|
|
||||||
+ hwaddr iova, end;
|
|
||||||
+ Int128 llend, llsize;
|
|
||||||
+ int ret;
|
|
||||||
+ bool try_unmap = true;
|
|
||||||
|
|
||||||
if (vfio_listener_skipped_section(section)) {
|
|
||||||
trace_vfio_listener_region_del_skip(
|
|
||||||
@@ -1282,7 +1200,53 @@ static void vfio_listener_region_del(MemoryListener *listener,
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
- vfio_dma_unmap_ram_section(container, section);
|
|
||||||
+ iova = REAL_HOST_PAGE_ALIGN(section->offset_within_address_space);
|
|
||||||
+ llend = int128_make64(section->offset_within_address_space);
|
|
||||||
+ llend = int128_add(llend, section->size);
|
|
||||||
+ llend = int128_and(llend, int128_exts64(qemu_real_host_page_mask));
|
|
||||||
+
|
|
||||||
+ if (int128_ge(int128_make64(iova), llend)) {
|
|
||||||
+ return;
|
|
||||||
+ }
|
|
||||||
+ end = int128_get64(int128_sub(llend, int128_one()));
|
|
||||||
+
|
|
||||||
+ llsize = int128_sub(llend, int128_make64(iova));
|
|
||||||
+
|
|
||||||
+ trace_vfio_listener_region_del(iova, end);
|
|
||||||
+
|
|
||||||
+ if (memory_region_is_ram_device(section->mr)) {
|
|
||||||
+ hwaddr pgmask;
|
|
||||||
+ VFIOHostDMAWindow *hostwin = hostwin_from_range(container, iova, end);
|
|
||||||
+
|
|
||||||
+ assert(hostwin); /* or region_add() would have failed */
|
|
||||||
+
|
|
||||||
+ pgmask = (1ULL << ctz64(hostwin->iova_pgsizes)) - 1;
|
|
||||||
+ try_unmap = !((iova & pgmask) || (int128_get64(llsize) & pgmask));
|
|
||||||
+ } else if (memory_region_has_ram_discard_manager(section->mr)) {
|
|
||||||
+ vfio_unregister_ram_discard_listener(container, section);
|
|
||||||
+ /* Unregistering will trigger an unmap. */
|
|
||||||
+ try_unmap = false;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ if (try_unmap) {
|
|
||||||
+ if (int128_eq(llsize, int128_2_64())) {
|
|
||||||
+ /* The unmap ioctl doesn't accept a full 64-bit span. */
|
|
||||||
+ llsize = int128_rshift(llsize, 1);
|
|
||||||
+ ret = vfio_dma_unmap(container, iova, int128_get64(llsize), NULL);
|
|
||||||
+ if (ret) {
|
|
||||||
+ error_report("vfio_dma_unmap(%p, 0x%"HWADDR_PRIx", "
|
|
||||||
+ "0x%"HWADDR_PRIx") = %d (%m)",
|
|
||||||
+ container, iova, int128_get64(llsize), ret);
|
|
||||||
+ }
|
|
||||||
+ iova += int128_get64(llsize);
|
|
||||||
+ }
|
|
||||||
+ ret = vfio_dma_unmap(container, iova, int128_get64(llsize), NULL);
|
|
||||||
+ if (ret) {
|
|
||||||
+ error_report("vfio_dma_unmap(%p, 0x%"HWADDR_PRIx", "
|
|
||||||
+ "0x%"HWADDR_PRIx") = %d (%m)",
|
|
||||||
+ container, iova, int128_get64(llsize), ret);
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
|
|
||||||
memory_region_unref(section->mr);
|
|
||||||
|
|
||||||
diff --git a/hw/vfio/trace-events b/hw/vfio/trace-events
|
|
||||||
index a37563a315..0ef1b5f4a6 100644
|
|
||||||
--- a/hw/vfio/trace-events
|
|
||||||
+++ b/hw/vfio/trace-events
|
|
||||||
@@ -99,10 +99,10 @@ vfio_iommu_map_notify(const char *op, uint64_t iova_start, uint64_t iova_end) "i
|
|
||||||
vfio_listener_region_add_skip(uint64_t start, uint64_t end) "SKIPPING region_add 0x%"PRIx64" - 0x%"PRIx64
|
|
||||||
vfio_spapr_group_attach(int groupfd, int tablefd) "Attached groupfd %d to liobn fd %d"
|
|
||||||
vfio_listener_region_add_iommu(uint64_t start, uint64_t end) "region_add [iommu] 0x%"PRIx64" - 0x%"PRIx64
|
|
||||||
-vfio_dma_map_ram(uint64_t iova_start, uint64_t iova_end, void *vaddr) "region_add [ram] 0x%"PRIx64" - 0x%"PRIx64" [%p]"
|
|
||||||
+vfio_listener_region_add_ram(uint64_t iova_start, uint64_t iova_end, void *vaddr) "region_add [ram] 0x%"PRIx64" - 0x%"PRIx64" [%p]"
|
|
||||||
vfio_listener_region_add_no_dma_map(const char *name, uint64_t iova, uint64_t size, uint64_t page_size) "Region \"%s\" 0x%"PRIx64" size=0x%"PRIx64" is not aligned to 0x%"PRIx64" and cannot be mapped for DMA"
|
|
||||||
vfio_listener_region_del_skip(uint64_t start, uint64_t end) "SKIPPING region_del 0x%"PRIx64" - 0x%"PRIx64
|
|
||||||
-vfio_dma_unmap_ram(uint64_t start, uint64_t end) "region_del 0x%"PRIx64" - 0x%"PRIx64
|
|
||||||
+vfio_listener_region_del(uint64_t start, uint64_t end) "region_del 0x%"PRIx64" - 0x%"PRIx64
|
|
||||||
vfio_disconnect_container(int fd) "close container->fd=%d"
|
|
||||||
vfio_put_group(int fd) "close group->fd=%d"
|
|
||||||
vfio_get_device(const char * name, unsigned int flags, unsigned int num_regions, unsigned int num_irqs) "Device %s flags: %u, regions: %u, irqs: %u"
|
|
||||||
--
|
|
||||||
2.27.0
|
|
||||||
|
|
||||||
@ -1,63 +0,0 @@
|
|||||||
From 9664a2d7b040a41d75067f4c58bf72c705e4a13b Mon Sep 17 00:00:00 2001
|
|
||||||
From: Kunkun Jiang <jiangkunkun@huawei.com>
|
|
||||||
Date: Fri, 18 Nov 2022 15:22:23 +0800
|
|
||||||
Subject: [PATCH 07/36] Revert "vfio: Introduce helpers to mark dirty pages of
|
|
||||||
a RAM section"
|
|
||||||
|
|
||||||
This reverts commit 1675d767aa9bd496178b4d74e01a40dbbd97eccb.
|
|
||||||
|
|
||||||
Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com>
|
|
||||||
---
|
|
||||||
hw/vfio/common.c | 22 ++++++++--------------
|
|
||||||
1 file changed, 8 insertions(+), 14 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/hw/vfio/common.c b/hw/vfio/common.c
|
|
||||||
index 6136b1ef61..bdfcc854fe 100644
|
|
||||||
--- a/hw/vfio/common.c
|
|
||||||
+++ b/hw/vfio/common.c
|
|
||||||
@@ -1566,19 +1566,6 @@ err_out:
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
-static int vfio_dma_sync_ram_section_dirty_bitmap(VFIOContainer *container,
|
|
||||||
- MemoryRegionSection *section)
|
|
||||||
-{
|
|
||||||
- ram_addr_t ram_addr;
|
|
||||||
-
|
|
||||||
- ram_addr = memory_region_get_ram_addr(section->mr) +
|
|
||||||
- section->offset_within_region;
|
|
||||||
-
|
|
||||||
- return vfio_get_dirty_bitmap(container,
|
|
||||||
- REAL_HOST_PAGE_ALIGN(section->offset_within_address_space),
|
|
||||||
- int128_get64(section->size), ram_addr);
|
|
||||||
-}
|
|
||||||
-
|
|
||||||
typedef struct {
|
|
||||||
IOMMUNotifier n;
|
|
||||||
VFIOGuestIOMMU *giommu;
|
|
||||||
@@ -1663,6 +1650,8 @@ static int vfio_sync_ram_discard_listener_dirty_bitmap(VFIOContainer *container,
|
|
||||||
static int vfio_sync_dirty_bitmap(VFIOContainer *container,
|
|
||||||
MemoryRegionSection *section)
|
|
||||||
{
|
|
||||||
+ ram_addr_t ram_addr;
|
|
||||||
+
|
|
||||||
if (memory_region_is_iommu(section->mr)) {
|
|
||||||
VFIOGuestIOMMU *giommu;
|
|
||||||
|
|
||||||
@@ -1693,7 +1682,12 @@ static int vfio_sync_dirty_bitmap(VFIOContainer *container,
|
|
||||||
return vfio_sync_ram_discard_listener_dirty_bitmap(container, section);
|
|
||||||
}
|
|
||||||
|
|
||||||
- return vfio_dma_sync_ram_section_dirty_bitmap(container, section);
|
|
||||||
+ ram_addr = memory_region_get_ram_addr(section->mr) +
|
|
||||||
+ section->offset_within_region;
|
|
||||||
+
|
|
||||||
+ return vfio_get_dirty_bitmap(container,
|
|
||||||
+ REAL_HOST_PAGE_ALIGN(section->offset_within_address_space),
|
|
||||||
+ int128_get64(section->size), ram_addr);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void vfio_listener_log_sync(MemoryListener *listener,
|
|
||||||
--
|
|
||||||
2.27.0
|
|
||||||
|
|
||||||
@ -1,84 +0,0 @@
|
|||||||
From 66fce3f7e9754345cf53afe3efd1b5bb5e322399 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Kunkun Jiang <jiangkunkun@huawei.com>
|
|
||||||
Date: Fri, 18 Nov 2022 15:22:46 +0800
|
|
||||||
Subject: [PATCH 25/36] Revert "vfio: Introduce hostwin_from_range helper"
|
|
||||||
|
|
||||||
This reverts commit 85232739b4852f1a51dde58c9007ed0deb17c2f2.
|
|
||||||
|
|
||||||
Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com>
|
|
||||||
---
|
|
||||||
hw/vfio/common.c | 36 +++++++++++++++++++-----------------
|
|
||||||
1 file changed, 19 insertions(+), 17 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/hw/vfio/common.c b/hw/vfio/common.c
|
|
||||||
index d358789f19..d7533637c9 100644
|
|
||||||
--- a/hw/vfio/common.c
|
|
||||||
+++ b/hw/vfio/common.c
|
|
||||||
@@ -909,19 +909,6 @@ static void vfio_unregister_ram_discard_listener(VFIOContainer *container,
|
|
||||||
g_free(vrdl);
|
|
||||||
}
|
|
||||||
|
|
||||||
-static VFIOHostDMAWindow *
|
|
||||||
-hostwin_from_range(VFIOContainer *container, hwaddr iova, hwaddr end)
|
|
||||||
-{
|
|
||||||
- VFIOHostDMAWindow *hostwin;
|
|
||||||
-
|
|
||||||
- QLIST_FOREACH(hostwin, &container->hostwin_list, hostwin_next) {
|
|
||||||
- if (hostwin->min_iova <= iova && end <= hostwin->max_iova) {
|
|
||||||
- return hostwin;
|
|
||||||
- }
|
|
||||||
- }
|
|
||||||
- return NULL;
|
|
||||||
-}
|
|
||||||
-
|
|
||||||
static void vfio_listener_region_add(MemoryListener *listener,
|
|
||||||
MemoryRegionSection *section)
|
|
||||||
{
|
|
||||||
@@ -931,6 +918,7 @@ static void vfio_listener_region_add(MemoryListener *listener,
|
|
||||||
void *vaddr;
|
|
||||||
int ret;
|
|
||||||
VFIOHostDMAWindow *hostwin;
|
|
||||||
+ bool hostwin_found;
|
|
||||||
Error *err = NULL;
|
|
||||||
|
|
||||||
if (vfio_listener_skipped_section(section)) {
|
|
||||||
@@ -1023,8 +1011,15 @@ static void vfio_listener_region_add(MemoryListener *listener,
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
- hostwin = hostwin_from_range(container, iova, end);
|
|
||||||
- if (!hostwin) {
|
|
||||||
+ hostwin_found = false;
|
|
||||||
+ QLIST_FOREACH(hostwin, &container->hostwin_list, hostwin_next) {
|
|
||||||
+ if (hostwin->min_iova <= iova && end <= hostwin->max_iova) {
|
|
||||||
+ hostwin_found = true;
|
|
||||||
+ break;
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ if (!hostwin_found) {
|
|
||||||
error_setg(&err, "Container %p can't map guest IOVA region"
|
|
||||||
" 0x%"HWADDR_PRIx"..0x%"HWADDR_PRIx, container, iova, end);
|
|
||||||
goto fail;
|
|
||||||
@@ -1216,9 +1211,16 @@ static void vfio_listener_region_del(MemoryListener *listener,
|
|
||||||
|
|
||||||
if (memory_region_is_ram_device(section->mr)) {
|
|
||||||
hwaddr pgmask;
|
|
||||||
- VFIOHostDMAWindow *hostwin = hostwin_from_range(container, iova, end);
|
|
||||||
+ VFIOHostDMAWindow *hostwin;
|
|
||||||
+ bool hostwin_found = false;
|
|
||||||
|
|
||||||
- assert(hostwin); /* or region_add() would have failed */
|
|
||||||
+ QLIST_FOREACH(hostwin, &container->hostwin_list, hostwin_next) {
|
|
||||||
+ if (hostwin->min_iova <= iova && end <= hostwin->max_iova) {
|
|
||||||
+ hostwin_found = true;
|
|
||||||
+ break;
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+ assert(hostwin_found); /* or region_add() would have failed */
|
|
||||||
|
|
||||||
pgmask = (1ULL << ctz64(hostwin->iova_pgsizes)) - 1;
|
|
||||||
try_unmap = !((iova & pgmask) || (int128_get64(llsize) & pgmask));
|
|
||||||
--
|
|
||||||
2.27.0
|
|
||||||
|
|
||||||
@ -1,260 +0,0 @@
|
|||||||
From 17190414cd411d23f1fc14c3d44d7b9f210f12b0 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Kunkun Jiang <jiangkunkun@huawei.com>
|
|
||||||
Date: Fri, 18 Nov 2022 15:22:42 +0800
|
|
||||||
Subject: [PATCH 22/36] Revert "vfio: Pass stage 1 MSI bindings to the host"
|
|
||||||
|
|
||||||
This reverts commit 8b4fbe869f8a1f510896c86067d2e4fc3dc82eb9.
|
|
||||||
|
|
||||||
Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com>
|
|
||||||
---
|
|
||||||
hw/vfio/common.c | 59 ---------------------------
|
|
||||||
hw/vfio/pci.c | 76 +----------------------------------
|
|
||||||
hw/vfio/trace-events | 2 -
|
|
||||||
include/hw/vfio/vfio-common.h | 12 ------
|
|
||||||
4 files changed, 2 insertions(+), 147 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/hw/vfio/common.c b/hw/vfio/common.c
|
|
||||||
index 1f78af121d..58f8a43a43 100644
|
|
||||||
--- a/hw/vfio/common.c
|
|
||||||
+++ b/hw/vfio/common.c
|
|
||||||
@@ -774,65 +774,6 @@ static void vfio_iommu_unmap_notify(IOMMUNotifier *n, IOMMUTLBEntry *iotlb)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
-int vfio_iommu_set_msi_binding(VFIOContainer *container, int n,
|
|
||||||
- IOMMUTLBEntry *iotlb)
|
|
||||||
-{
|
|
||||||
- struct vfio_iommu_type1_set_msi_binding ustruct;
|
|
||||||
- VFIOMSIBinding *binding;
|
|
||||||
- int ret;
|
|
||||||
-
|
|
||||||
- QLIST_FOREACH(binding, &container->msibinding_list, next) {
|
|
||||||
- if (binding->index == n) {
|
|
||||||
- return 0;
|
|
||||||
- }
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
- ustruct.argsz = sizeof(struct vfio_iommu_type1_set_msi_binding);
|
|
||||||
- ustruct.iova = iotlb->iova;
|
|
||||||
- ustruct.flags = VFIO_IOMMU_BIND_MSI;
|
|
||||||
- ustruct.gpa = iotlb->translated_addr;
|
|
||||||
- ustruct.size = iotlb->addr_mask + 1;
|
|
||||||
- ret = ioctl(container->fd, VFIO_IOMMU_SET_MSI_BINDING , &ustruct);
|
|
||||||
- if (ret) {
|
|
||||||
- error_report("%s: failed to register the stage1 MSI binding (%m)",
|
|
||||||
- __func__);
|
|
||||||
- return ret;
|
|
||||||
- }
|
|
||||||
- binding = g_new0(VFIOMSIBinding, 1);
|
|
||||||
- binding->iova = ustruct.iova;
|
|
||||||
- binding->gpa = ustruct.gpa;
|
|
||||||
- binding->size = ustruct.size;
|
|
||||||
- binding->index = n;
|
|
||||||
-
|
|
||||||
- QLIST_INSERT_HEAD(&container->msibinding_list, binding, next);
|
|
||||||
- return 0;
|
|
||||||
-}
|
|
||||||
-
|
|
||||||
-int vfio_iommu_unset_msi_binding(VFIOContainer *container, int n)
|
|
||||||
-{
|
|
||||||
- struct vfio_iommu_type1_set_msi_binding ustruct;
|
|
||||||
- VFIOMSIBinding *binding, *tmp;
|
|
||||||
- int ret;
|
|
||||||
-
|
|
||||||
- ustruct.argsz = sizeof(struct vfio_iommu_type1_set_msi_binding);
|
|
||||||
- QLIST_FOREACH_SAFE(binding, &container->msibinding_list, next, tmp) {
|
|
||||||
- if (binding->index != n) {
|
|
||||||
- continue;
|
|
||||||
- }
|
|
||||||
- ustruct.flags = VFIO_IOMMU_UNBIND_MSI;
|
|
||||||
- ustruct.iova = binding->iova;
|
|
||||||
- ret = ioctl(container->fd, VFIO_IOMMU_SET_MSI_BINDING , &ustruct);
|
|
||||||
- if (ret) {
|
|
||||||
- error_report("Failed to unregister the stage1 MSI binding "
|
|
||||||
- "for iova=0x%"PRIx64" (%m)", binding->iova);
|
|
||||||
- }
|
|
||||||
- QLIST_REMOVE(binding, next);
|
|
||||||
- g_free(binding);
|
|
||||||
- return ret;
|
|
||||||
- }
|
|
||||||
- return 0;
|
|
||||||
-}
|
|
||||||
-
|
|
||||||
static void vfio_iommu_map_notify(IOMMUNotifier *n, IOMMUTLBEntry *iotlb)
|
|
||||||
{
|
|
||||||
VFIOGuestIOMMU *giommu = container_of(n, VFIOGuestIOMMU, n);
|
|
||||||
diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
|
|
||||||
index 99c52a0944..ae5e014e5d 100644
|
|
||||||
--- a/hw/vfio/pci.c
|
|
||||||
+++ b/hw/vfio/pci.c
|
|
||||||
@@ -365,65 +365,6 @@ static void vfio_msi_interrupt(void *opaque)
|
|
||||||
notify(&vdev->pdev, nr);
|
|
||||||
}
|
|
||||||
|
|
||||||
-static bool vfio_iommu_require_msi_binding(IOMMUMemoryRegion *iommu_mr)
|
|
||||||
-{
|
|
||||||
- bool msi_translate = false, nested = false;
|
|
||||||
-
|
|
||||||
- memory_region_iommu_get_attr(iommu_mr, IOMMU_ATTR_MSI_TRANSLATE,
|
|
||||||
- (void *)&msi_translate);
|
|
||||||
- memory_region_iommu_get_attr(iommu_mr, IOMMU_ATTR_VFIO_NESTED,
|
|
||||||
- (void *)&nested);
|
|
||||||
- if (!nested || !msi_translate) {
|
|
||||||
- return false;
|
|
||||||
- }
|
|
||||||
- return true;
|
|
||||||
-}
|
|
||||||
-
|
|
||||||
-static int vfio_register_msi_binding(VFIOPCIDevice *vdev,
|
|
||||||
- int vector_n, bool set)
|
|
||||||
-{
|
|
||||||
- VFIOContainer *container = vdev->vbasedev.group->container;
|
|
||||||
- PCIDevice *dev = &vdev->pdev;
|
|
||||||
- AddressSpace *as = pci_device_iommu_address_space(dev);
|
|
||||||
- IOMMUMemoryRegionClass *imrc;
|
|
||||||
- IOMMUMemoryRegion *iommu_mr;
|
|
||||||
- IOMMUTLBEntry entry;
|
|
||||||
- MSIMessage msg;
|
|
||||||
-
|
|
||||||
- if (as == &address_space_memory) {
|
|
||||||
- return 0;
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
- iommu_mr = IOMMU_MEMORY_REGION(as->root);
|
|
||||||
- if (!vfio_iommu_require_msi_binding(iommu_mr)) {
|
|
||||||
- return 0;
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
- /* MSI doorbell address is translated by an IOMMU */
|
|
||||||
-
|
|
||||||
- if (!set) { /* unregister */
|
|
||||||
- trace_vfio_unregister_msi_binding(vdev->vbasedev.name, vector_n);
|
|
||||||
-
|
|
||||||
- return vfio_iommu_unset_msi_binding(container, vector_n);
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
- msg = pci_get_msi_message(dev, vector_n);
|
|
||||||
- imrc = memory_region_get_iommu_class_nocheck(iommu_mr);
|
|
||||||
-
|
|
||||||
- rcu_read_lock();
|
|
||||||
- entry = imrc->translate(iommu_mr, msg.address, IOMMU_WO, 0);
|
|
||||||
- rcu_read_unlock();
|
|
||||||
-
|
|
||||||
- if (entry.perm == IOMMU_NONE) {
|
|
||||||
- return -ENOENT;
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
- trace_vfio_register_msi_binding(vdev->vbasedev.name, vector_n,
|
|
||||||
- msg.address, entry.translated_addr);
|
|
||||||
-
|
|
||||||
- return vfio_iommu_set_msi_binding(container, vector_n, &entry);
|
|
||||||
-}
|
|
||||||
-
|
|
||||||
static int vfio_enable_vectors(VFIOPCIDevice *vdev, bool msix)
|
|
||||||
{
|
|
||||||
struct vfio_irq_set *irq_set;
|
|
||||||
@@ -441,7 +382,7 @@ static int vfio_enable_vectors(VFIOPCIDevice *vdev, bool msix)
|
|
||||||
fds = (int32_t *)&irq_set->data;
|
|
||||||
|
|
||||||
for (i = 0; i < vdev->nr_vectors; i++) {
|
|
||||||
- int ret, fd = -1;
|
|
||||||
+ int fd = -1;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* MSI vs MSI-X - The guest has direct access to MSI mask and pending
|
|
||||||
@@ -450,12 +391,6 @@ static int vfio_enable_vectors(VFIOPCIDevice *vdev, bool msix)
|
|
||||||
* KVM signaling path only when configured and unmasked.
|
|
||||||
*/
|
|
||||||
if (vdev->msi_vectors[i].use) {
|
|
||||||
- ret = vfio_register_msi_binding(vdev, i, true);
|
|
||||||
- if (ret) {
|
|
||||||
- error_report("%s failed to register S1 MSI binding "
|
|
||||||
- "for vector %d(%d)", vdev->vbasedev.name, i, ret);
|
|
||||||
- goto out;
|
|
||||||
- }
|
|
||||||
if (vdev->msi_vectors[i].virq < 0 ||
|
|
||||||
(msix && msix_is_masked(&vdev->pdev, i))) {
|
|
||||||
fd = event_notifier_get_fd(&vdev->msi_vectors[i].interrupt);
|
|
||||||
@@ -469,7 +404,6 @@ static int vfio_enable_vectors(VFIOPCIDevice *vdev, bool msix)
|
|
||||||
|
|
||||||
ret = ioctl(vdev->vbasedev.fd, VFIO_DEVICE_SET_IRQS, irq_set);
|
|
||||||
|
|
||||||
-out:
|
|
||||||
g_free(irq_set);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
@@ -784,8 +718,7 @@ static void vfio_msi_disable_common(VFIOPCIDevice *vdev)
|
|
||||||
|
|
||||||
static void vfio_msix_disable(VFIOPCIDevice *vdev)
|
|
||||||
{
|
|
||||||
- int ret, i;
|
|
||||||
-
|
|
||||||
+ int i;
|
|
||||||
|
|
||||||
msix_unset_vector_notifiers(&vdev->pdev);
|
|
||||||
|
|
||||||
@@ -797,11 +730,6 @@ static void vfio_msix_disable(VFIOPCIDevice *vdev)
|
|
||||||
if (vdev->msi_vectors[i].use) {
|
|
||||||
vfio_msix_vector_release(&vdev->pdev, i);
|
|
||||||
msix_vector_unuse(&vdev->pdev, i);
|
|
||||||
- ret = vfio_register_msi_binding(vdev, i, false);
|
|
||||||
- if (ret) {
|
|
||||||
- error_report("%s: failed to unregister S1 MSI binding "
|
|
||||||
- "for vector %d(%d)", vdev->vbasedev.name, i, ret);
|
|
||||||
- }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
diff --git a/hw/vfio/trace-events b/hw/vfio/trace-events
|
|
||||||
index 35bd415d6d..20069935f5 100644
|
|
||||||
--- a/hw/vfio/trace-events
|
|
||||||
+++ b/hw/vfio/trace-events
|
|
||||||
@@ -120,8 +120,6 @@ vfio_get_dev_region(const char *name, int index, uint32_t type, uint32_t subtype
|
|
||||||
vfio_dma_unmap_overflow_workaround(void) ""
|
|
||||||
vfio_iommu_addr_inv_iotlb(int asid, uint64_t addr, uint64_t size, uint64_t nb_granules, bool leaf) "nested IOTLB invalidate asid=%d, addr=0x%"PRIx64" granule_size=0x%"PRIx64" nb_granules=0x%"PRIx64" leaf=%d"
|
|
||||||
vfio_iommu_asid_inv_iotlb(int asid) "nested IOTLB invalidate asid=%d"
|
|
||||||
-vfio_register_msi_binding(const char *name, int vector, uint64_t giova, uint64_t gdb) "%s: register vector %d gIOVA=0x%"PRIx64 "-> gDB=0x%"PRIx64" stage 1 mapping"
|
|
||||||
-vfio_unregister_msi_binding(const char *name, int vector) "%s: unregister vector %d stage 1 mapping"
|
|
||||||
|
|
||||||
# platform.c
|
|
||||||
vfio_platform_base_device_init(char *name, int groupid) "%s belongs to group #%d"
|
|
||||||
diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h
|
|
||||||
index a838a939e4..0234f5e1b1 100644
|
|
||||||
--- a/include/hw/vfio/vfio-common.h
|
|
||||||
+++ b/include/hw/vfio/vfio-common.h
|
|
||||||
@@ -74,14 +74,6 @@ typedef struct VFIOAddressSpace {
|
|
||||||
QLIST_ENTRY(VFIOAddressSpace) list;
|
|
||||||
} VFIOAddressSpace;
|
|
||||||
|
|
||||||
-typedef struct VFIOMSIBinding {
|
|
||||||
- int index;
|
|
||||||
- hwaddr iova;
|
|
||||||
- hwaddr gpa;
|
|
||||||
- hwaddr size;
|
|
||||||
- QLIST_ENTRY(VFIOMSIBinding) next;
|
|
||||||
-} VFIOMSIBinding;
|
|
||||||
-
|
|
||||||
struct VFIOGroup;
|
|
||||||
|
|
||||||
typedef struct VFIODMARange {
|
|
||||||
@@ -111,7 +103,6 @@ typedef struct VFIOContainer {
|
|
||||||
QLIST_HEAD(, VFIOGroup) group_list;
|
|
||||||
QLIST_HEAD(, VFIORamDiscardListener) vrdl_list;
|
|
||||||
QLIST_HEAD(, VFIODMARange) dma_list;
|
|
||||||
- QLIST_HEAD(, VFIOMSIBinding) msibinding_list;
|
|
||||||
QLIST_ENTRY(VFIOContainer) next;
|
|
||||||
} VFIOContainer;
|
|
||||||
|
|
||||||
@@ -231,9 +222,6 @@ VFIOGroup *vfio_get_group(int groupid, AddressSpace *as, Error **errp);
|
|
||||||
void vfio_put_group(VFIOGroup *group);
|
|
||||||
int vfio_get_device(VFIOGroup *group, const char *name,
|
|
||||||
VFIODevice *vbasedev, Error **errp);
|
|
||||||
-int vfio_iommu_set_msi_binding(VFIOContainer *container, int n,
|
|
||||||
- IOMMUTLBEntry *entry);
|
|
||||||
-int vfio_iommu_unset_msi_binding(VFIOContainer *container, int n);
|
|
||||||
|
|
||||||
extern const MemoryRegionOps vfio_region_ops;
|
|
||||||
typedef QLIST_HEAD(VFIOGroupList, VFIOGroup) VFIOGroupList;
|
|
||||||
--
|
|
||||||
2.27.0
|
|
||||||
|
|
||||||
@ -1,266 +0,0 @@
|
|||||||
From 72b7903e406b7011ccba7a3ebbdfe790b421e9fc Mon Sep 17 00:00:00 2001
|
|
||||||
From: Kunkun Jiang <jiangkunkun@huawei.com>
|
|
||||||
Date: Fri, 18 Nov 2022 15:22:43 +0800
|
|
||||||
Subject: [PATCH 23/36] Revert "vfio: Set up nested stage mappings"
|
|
||||||
|
|
||||||
This reverts commit 96581a5ee46e89dbc9e1ebe247b00adefb1c7a41.
|
|
||||||
|
|
||||||
Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com>
|
|
||||||
---
|
|
||||||
hw/vfio/common.c | 139 ++-----------------------------------------
|
|
||||||
hw/vfio/pci.c | 21 -------
|
|
||||||
hw/vfio/trace-events | 2 -
|
|
||||||
3 files changed, 5 insertions(+), 157 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/hw/vfio/common.c b/hw/vfio/common.c
|
|
||||||
index 58f8a43a43..b3dc090840 100644
|
|
||||||
--- a/hw/vfio/common.c
|
|
||||||
+++ b/hw/vfio/common.c
|
|
||||||
@@ -707,73 +707,6 @@ static bool vfio_get_xlat_addr(IOMMUTLBEntry *iotlb, void **vaddr,
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
-/* Propagate a guest IOTLB invalidation to the host (nested mode) */
|
|
||||||
-static void vfio_iommu_unmap_notify(IOMMUNotifier *n, IOMMUTLBEntry *iotlb)
|
|
||||||
-{
|
|
||||||
- VFIOGuestIOMMU *giommu = container_of(n, VFIOGuestIOMMU, n);
|
|
||||||
- struct vfio_iommu_type1_cache_invalidate ustruct = {};
|
|
||||||
- VFIOContainer *container = giommu->container;
|
|
||||||
- int ret;
|
|
||||||
-
|
|
||||||
- assert(iotlb->perm == IOMMU_NONE);
|
|
||||||
-
|
|
||||||
- ustruct.argsz = sizeof(ustruct);
|
|
||||||
- ustruct.flags = 0;
|
|
||||||
- ustruct.info.argsz = sizeof(struct iommu_cache_invalidate_info);
|
|
||||||
- ustruct.info.version = IOMMU_CACHE_INVALIDATE_INFO_VERSION_1;
|
|
||||||
- ustruct.info.cache = IOMMU_CACHE_INV_TYPE_IOTLB;
|
|
||||||
-
|
|
||||||
- switch (iotlb->granularity) {
|
|
||||||
- case IOMMU_INV_GRAN_DOMAIN:
|
|
||||||
- ustruct.info.granularity = IOMMU_INV_GRANU_DOMAIN;
|
|
||||||
- break;
|
|
||||||
- case IOMMU_INV_GRAN_PASID:
|
|
||||||
- {
|
|
||||||
- struct iommu_inv_pasid_info *pasid_info;
|
|
||||||
- int archid = -1;
|
|
||||||
-
|
|
||||||
- pasid_info = &ustruct.info.granu.pasid_info;
|
|
||||||
- ustruct.info.granularity = IOMMU_INV_GRANU_PASID;
|
|
||||||
- if (iotlb->flags & IOMMU_INV_FLAGS_ARCHID) {
|
|
||||||
- pasid_info->flags |= IOMMU_INV_ADDR_FLAGS_ARCHID;
|
|
||||||
- archid = iotlb->arch_id;
|
|
||||||
- }
|
|
||||||
- pasid_info->archid = archid;
|
|
||||||
- trace_vfio_iommu_asid_inv_iotlb(archid);
|
|
||||||
- break;
|
|
||||||
- }
|
|
||||||
- case IOMMU_INV_GRAN_ADDR:
|
|
||||||
- {
|
|
||||||
- hwaddr start = iotlb->iova + giommu->iommu_offset;
|
|
||||||
- struct iommu_inv_addr_info *addr_info;
|
|
||||||
- size_t size = iotlb->addr_mask + 1;
|
|
||||||
- int archid = -1;
|
|
||||||
-
|
|
||||||
- addr_info = &ustruct.info.granu.addr_info;
|
|
||||||
- ustruct.info.granularity = IOMMU_INV_GRANU_ADDR;
|
|
||||||
- if (iotlb->leaf) {
|
|
||||||
- addr_info->flags |= IOMMU_INV_ADDR_FLAGS_LEAF;
|
|
||||||
- }
|
|
||||||
- if (iotlb->flags & IOMMU_INV_FLAGS_ARCHID) {
|
|
||||||
- addr_info->flags |= IOMMU_INV_ADDR_FLAGS_ARCHID;
|
|
||||||
- archid = iotlb->arch_id;
|
|
||||||
- }
|
|
||||||
- addr_info->archid = archid;
|
|
||||||
- addr_info->addr = start;
|
|
||||||
- addr_info->granule_size = size;
|
|
||||||
- addr_info->nb_granules = 1;
|
|
||||||
- trace_vfio_iommu_addr_inv_iotlb(archid, start, size,
|
|
||||||
- 1, iotlb->leaf);
|
|
||||||
- break;
|
|
||||||
- }
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
- ret = ioctl(container->fd, VFIO_IOMMU_CACHE_INVALIDATE, &ustruct);
|
|
||||||
- if (ret) {
|
|
||||||
- error_report("%p: failed to invalidate CACHE (%d)", container, ret);
|
|
||||||
- }
|
|
||||||
-}
|
|
||||||
-
|
|
||||||
static void vfio_iommu_map_notify(IOMMUNotifier *n, IOMMUTLBEntry *iotlb)
|
|
||||||
{
|
|
||||||
VFIOGuestIOMMU *giommu = container_of(n, VFIOGuestIOMMU, n);
|
|
||||||
@@ -1107,35 +1040,6 @@ static void vfio_dma_unmap_ram_section(VFIOContainer *container,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
-static void vfio_prereg_listener_region_add(MemoryListener *listener,
|
|
||||||
- MemoryRegionSection *section)
|
|
||||||
-{
|
|
||||||
- VFIOContainer *container =
|
|
||||||
- container_of(listener, VFIOContainer, prereg_listener);
|
|
||||||
- Error *err = NULL;
|
|
||||||
-
|
|
||||||
- if (!memory_region_is_ram(section->mr)) {
|
|
||||||
- return;
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
- vfio_dma_map_ram_section(container, section, &err);
|
|
||||||
- if (err) {
|
|
||||||
- error_report_err(err);
|
|
||||||
- }
|
|
||||||
-}
|
|
||||||
-static void vfio_prereg_listener_region_del(MemoryListener *listener,
|
|
||||||
- MemoryRegionSection *section)
|
|
||||||
-{
|
|
||||||
- VFIOContainer *container =
|
|
||||||
- container_of(listener, VFIOContainer, prereg_listener);
|
|
||||||
-
|
|
||||||
- if (!memory_region_is_ram(section->mr)) {
|
|
||||||
- return;
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
- vfio_dma_unmap_ram_section(container, section);
|
|
||||||
-}
|
|
||||||
-
|
|
||||||
static void vfio_listener_region_add(MemoryListener *listener,
|
|
||||||
MemoryRegionSection *section)
|
|
||||||
{
|
|
||||||
@@ -1246,10 +1150,9 @@ static void vfio_listener_region_add(MemoryListener *listener,
|
|
||||||
memory_region_ref(section->mr);
|
|
||||||
|
|
||||||
if (memory_region_is_iommu(section->mr)) {
|
|
||||||
- IOMMUNotify notify;
|
|
||||||
VFIOGuestIOMMU *giommu;
|
|
||||||
IOMMUMemoryRegion *iommu_mr = IOMMU_MEMORY_REGION(section->mr);
|
|
||||||
- int iommu_idx, flags;
|
|
||||||
+ int iommu_idx;
|
|
||||||
|
|
||||||
trace_vfio_listener_region_add_iommu(iova, end);
|
|
||||||
/*
|
|
||||||
@@ -1268,18 +1171,8 @@ static void vfio_listener_region_add(MemoryListener *listener,
|
|
||||||
llend = int128_sub(llend, int128_one());
|
|
||||||
iommu_idx = memory_region_iommu_attrs_to_index(iommu_mr,
|
|
||||||
MEMTXATTRS_UNSPECIFIED);
|
|
||||||
-
|
|
||||||
- if (container->iommu_type == VFIO_TYPE1_NESTING_IOMMU) {
|
|
||||||
- /* IOTLB unmap notifier to propagate guest IOTLB invalidations */
|
|
||||||
- flags = IOMMU_NOTIFIER_UNMAP;
|
|
||||||
- notify = vfio_iommu_unmap_notify;
|
|
||||||
- } else {
|
|
||||||
- /* MAP/UNMAP IOTLB notifier */
|
|
||||||
- flags = IOMMU_NOTIFIER_IOTLB_EVENTS;
|
|
||||||
- notify = vfio_iommu_map_notify;
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
- iommu_notifier_init(&giommu->n, notify, flags,
|
|
||||||
+ iommu_notifier_init(&giommu->n, vfio_iommu_map_notify,
|
|
||||||
+ IOMMU_NOTIFIER_IOTLB_EVENTS,
|
|
||||||
section->offset_within_region,
|
|
||||||
int128_get64(llend),
|
|
||||||
iommu_idx);
|
|
||||||
@@ -1299,9 +1192,7 @@ static void vfio_listener_region_add(MemoryListener *listener,
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
QLIST_INSERT_HEAD(&container->giommu_list, giommu, giommu_next);
|
|
||||||
- if (flags & IOMMU_NOTIFIER_MAP) {
|
|
||||||
- memory_region_iommu_replay(giommu->iommu, &giommu->n);
|
|
||||||
- }
|
|
||||||
+ memory_region_iommu_replay(giommu->iommu, &giommu->n);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
@@ -1781,16 +1672,10 @@ static const MemoryListener vfio_memory_listener = {
|
|
||||||
.log_clear = vfio_listener_log_clear,
|
|
||||||
};
|
|
||||||
|
|
||||||
-static MemoryListener vfio_memory_prereg_listener = {
|
|
||||||
- .region_add = vfio_prereg_listener_region_add,
|
|
||||||
- .region_del = vfio_prereg_listener_region_del,
|
|
||||||
-};
|
|
||||||
-
|
|
||||||
static void vfio_listener_release(VFIOContainer *container)
|
|
||||||
{
|
|
||||||
memory_listener_unregister(&container->listener);
|
|
||||||
- if (container->iommu_type == VFIO_SPAPR_TCE_v2_IOMMU ||
|
|
||||||
- container->iommu_type == VFIO_TYPE1_NESTING_IOMMU) {
|
|
||||||
+ if (container->iommu_type == VFIO_SPAPR_TCE_v2_IOMMU) {
|
|
||||||
memory_listener_unregister(&container->prereg_listener);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -2466,20 +2351,6 @@ static int vfio_connect_container(VFIOGroup *group, AddressSpace *as,
|
|
||||||
vfio_get_iommu_info_migration(container, info);
|
|
||||||
}
|
|
||||||
g_free(info);
|
|
||||||
-
|
|
||||||
- if (container->iommu_type == VFIO_TYPE1_NESTING_IOMMU) {
|
|
||||||
- container->prereg_listener = vfio_memory_prereg_listener;
|
|
||||||
- memory_listener_register(&container->prereg_listener,
|
|
||||||
- &address_space_memory);
|
|
||||||
- if (container->error) {
|
|
||||||
- memory_listener_unregister(&container->prereg_listener);
|
|
||||||
- ret = -1;
|
|
||||||
- error_propagate_prepend(errp, container->error,
|
|
||||||
- "RAM memory listener initialization failed "
|
|
||||||
- "for container");
|
|
||||||
- goto free_container_exit;
|
|
||||||
- }
|
|
||||||
- }
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case VFIO_SPAPR_TCE_v2_IOMMU:
|
|
||||||
diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
|
|
||||||
index ae5e014e5d..7b45353ce2 100644
|
|
||||||
--- a/hw/vfio/pci.c
|
|
||||||
+++ b/hw/vfio/pci.c
|
|
||||||
@@ -2797,25 +2797,6 @@ static void vfio_unregister_req_notifier(VFIOPCIDevice *vdev)
|
|
||||||
vdev->req_enabled = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
-static int vfio_iommu_set_pasid_table(PCIBus *bus, int32_t devfn,
|
|
||||||
- IOMMUConfig *config)
|
|
||||||
-{
|
|
||||||
- PCIDevice *pdev = bus->devices[devfn];
|
|
||||||
- VFIOPCIDevice *vdev = DO_UPCAST(VFIOPCIDevice, pdev, pdev);
|
|
||||||
- VFIOContainer *container = vdev->vbasedev.group->container;
|
|
||||||
- struct vfio_iommu_type1_set_pasid_table info;
|
|
||||||
-
|
|
||||||
- info.argsz = sizeof(info);
|
|
||||||
- info.flags = VFIO_PASID_TABLE_FLAG_SET;
|
|
||||||
- memcpy(&info.config, &config->pasid_cfg, sizeof(config->pasid_cfg));
|
|
||||||
-
|
|
||||||
- return ioctl(container->fd, VFIO_IOMMU_SET_PASID_TABLE, &info);
|
|
||||||
-}
|
|
||||||
-
|
|
||||||
-static PCIPASIDOps vfio_pci_pasid_ops = {
|
|
||||||
- .set_pasid_table = vfio_iommu_set_pasid_table,
|
|
||||||
-};
|
|
||||||
-
|
|
||||||
static void vfio_realize(PCIDevice *pdev, Error **errp)
|
|
||||||
{
|
|
||||||
VFIOPCIDevice *vdev = VFIO_PCI(pdev);
|
|
||||||
@@ -3127,8 +3108,6 @@ static void vfio_realize(PCIDevice *pdev, Error **errp)
|
|
||||||
vfio_register_req_notifier(vdev);
|
|
||||||
vfio_setup_resetfn_quirk(vdev);
|
|
||||||
|
|
||||||
- pci_setup_pasid_ops(pdev, &vfio_pci_pasid_ops);
|
|
||||||
-
|
|
||||||
return;
|
|
||||||
|
|
||||||
out_deregister:
|
|
||||||
diff --git a/hw/vfio/trace-events b/hw/vfio/trace-events
|
|
||||||
index 20069935f5..a37563a315 100644
|
|
||||||
--- a/hw/vfio/trace-events
|
|
||||||
+++ b/hw/vfio/trace-events
|
|
||||||
@@ -118,8 +118,6 @@ vfio_region_sparse_mmap_header(const char *name, int index, int nr_areas) "Devic
|
|
||||||
vfio_region_sparse_mmap_entry(int i, unsigned long start, unsigned long end) "sparse entry %d [0x%lx - 0x%lx]"
|
|
||||||
vfio_get_dev_region(const char *name, int index, uint32_t type, uint32_t subtype) "%s index %d, %08x/%0x8"
|
|
||||||
vfio_dma_unmap_overflow_workaround(void) ""
|
|
||||||
-vfio_iommu_addr_inv_iotlb(int asid, uint64_t addr, uint64_t size, uint64_t nb_granules, bool leaf) "nested IOTLB invalidate asid=%d, addr=0x%"PRIx64" granule_size=0x%"PRIx64" nb_granules=0x%"PRIx64" leaf=%d"
|
|
||||||
-vfio_iommu_asid_inv_iotlb(int asid) "nested IOTLB invalidate asid=%d"
|
|
||||||
|
|
||||||
# platform.c
|
|
||||||
vfio_platform_base_device_init(char *name, int groupid) "%s belongs to group #%d"
|
|
||||||
--
|
|
||||||
2.27.0
|
|
||||||
|
|
||||||
@ -1,44 +0,0 @@
|
|||||||
From d0a16f250666ebd38c059ca86f161fade23640cf Mon Sep 17 00:00:00 2001
|
|
||||||
From: Kunkun Jiang <jiangkunkun@huawei.com>
|
|
||||||
Date: Fri, 18 Nov 2022 15:22:09 +0800
|
|
||||||
Subject: [PATCH 01/36] Revert "vfio/common: Add address alignment check in
|
|
||||||
vfio_listener_region_del"
|
|
||||||
|
|
||||||
This reverts commit 00c553f53657bf4bc165d859187215dba7110246.
|
|
||||||
|
|
||||||
Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com>
|
|
||||||
---
|
|
||||||
hw/vfio/common.c | 10 ----------
|
|
||||||
1 file changed, 10 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/hw/vfio/common.c b/hw/vfio/common.c
|
|
||||||
index 4d45c2b625..89c49f5508 100644
|
|
||||||
--- a/hw/vfio/common.c
|
|
||||||
+++ b/hw/vfio/common.c
|
|
||||||
@@ -1411,8 +1411,6 @@ static void vfio_listener_region_del(MemoryListener *listener,
|
|
||||||
MemoryRegionSection *section)
|
|
||||||
{
|
|
||||||
VFIOContainer *container = container_of(listener, VFIOContainer, listener);
|
|
||||||
- hwaddr iova;
|
|
||||||
- Int128 llend;
|
|
||||||
|
|
||||||
if (vfio_listener_skipped_section(section)) {
|
|
||||||
trace_vfio_listener_region_del_skip(
|
|
||||||
@@ -1462,14 +1460,6 @@ static void vfio_listener_region_del(MemoryListener *listener,
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
- iova = REAL_HOST_PAGE_ALIGN(section->offset_within_address_space);
|
|
||||||
- llend = int128_make64(section->offset_within_address_space);
|
|
||||||
- llend = int128_add(llend, section->size);
|
|
||||||
- llend = int128_and(llend, int128_exts64(qemu_real_host_page_mask));
|
|
||||||
- if (int128_ge(int128_make64(iova), llend)) {
|
|
||||||
- return;
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
vfio_dma_unmap_ram_section(container, section);
|
|
||||||
|
|
||||||
memory_region_unref(section->mr);
|
|
||||||
--
|
|
||||||
2.27.0
|
|
||||||
|
|
||||||
@ -1,37 +0,0 @@
|
|||||||
From 2dc27b19fd8a17b23b112e84b9d7286d8c5f30ca Mon Sep 17 00:00:00 2001
|
|
||||||
From: Kunkun Jiang <jiangkunkun@huawei.com>
|
|
||||||
Date: Fri, 18 Nov 2022 15:22:25 +0800
|
|
||||||
Subject: [PATCH 08/36] Revert "vfio/common: Avoid unmap ram section at
|
|
||||||
vfio_listener_region_del() in nested mode"
|
|
||||||
|
|
||||||
This reverts commit 9d7b782a0b2c5288e82f3064b4c5b7bf18887280.
|
|
||||||
|
|
||||||
Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com>
|
|
||||||
---
|
|
||||||
hw/vfio/common.c | 10 ----------
|
|
||||||
1 file changed, 10 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/hw/vfio/common.c b/hw/vfio/common.c
|
|
||||||
index bdfcc854fe..d05a485808 100644
|
|
||||||
--- a/hw/vfio/common.c
|
|
||||||
+++ b/hw/vfio/common.c
|
|
||||||
@@ -1441,16 +1441,6 @@ static void vfio_listener_region_del(MemoryListener *listener,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
- /*
|
|
||||||
- * In nested mode, stage 2 (gpa->hpa) and the stage 1
|
|
||||||
- * (giova->gpa) are set separately. The ram section
|
|
||||||
- * will be unmapped in vfio_prereg_listener_region_del().
|
|
||||||
- * Hence it doesn't need to unmap ram section here.
|
|
||||||
- */
|
|
||||||
- if (container->iommu_type == VFIO_TYPE1_NESTING_IOMMU) {
|
|
||||||
- return;
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
/*
|
|
||||||
* FIXME: We assume the one big unmap below is adequate to
|
|
||||||
* remove any individual page mappings in the IOMMU which
|
|
||||||
--
|
|
||||||
2.27.0
|
|
||||||
|
|
||||||
@ -1,33 +0,0 @@
|
|||||||
From b5cee7126a75ea0e1797760fd5d7dfd89028b8a8 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Kunkun Jiang <jiangkunkun@huawei.com>
|
|
||||||
Date: Fri, 18 Nov 2022 15:22:14 +0800
|
|
||||||
Subject: [PATCH 02/36] Revert "vfio/common: Fix incorrect address alignment in
|
|
||||||
vfio_dma_map_ram_section"
|
|
||||||
|
|
||||||
This reverts commit c2a4ce033db6ab74256e28da382c797a98047d4b.
|
|
||||||
|
|
||||||
Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com>
|
|
||||||
---
|
|
||||||
hw/vfio/common.c | 4 ++--
|
|
||||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/hw/vfio/common.c b/hw/vfio/common.c
|
|
||||||
index 89c49f5508..65f3979492 100644
|
|
||||||
--- a/hw/vfio/common.c
|
|
||||||
+++ b/hw/vfio/common.c
|
|
||||||
@@ -1059,10 +1059,10 @@ static int vfio_dma_map_ram_section(VFIOContainer *container,
|
|
||||||
|
|
||||||
assert(memory_region_is_ram(section->mr));
|
|
||||||
|
|
||||||
- iova = REAL_HOST_PAGE_ALIGN(section->offset_within_address_space);
|
|
||||||
+ iova = TARGET_PAGE_ALIGN(section->offset_within_address_space);
|
|
||||||
llend = int128_make64(section->offset_within_address_space);
|
|
||||||
llend = int128_add(llend, section->size);
|
|
||||||
- llend = int128_and(llend, int128_exts64(qemu_real_host_page_mask));
|
|
||||||
+ llend = int128_and(llend, int128_exts64(TARGET_PAGE_MASK));
|
|
||||||
end = int128_get64(int128_sub(llend, int128_one()));
|
|
||||||
|
|
||||||
vaddr = memory_region_get_ram_ptr(section->mr) +
|
|
||||||
--
|
|
||||||
2.27.0
|
|
||||||
|
|
||||||
@ -1,194 +0,0 @@
|
|||||||
From 50e365a162cb7dd39d724fa1c5823e82d184af3a Mon Sep 17 00:00:00 2001
|
|
||||||
From: Kunkun Jiang <jiangkunkun@huawei.com>
|
|
||||||
Date: Fri, 18 Nov 2022 15:22:26 +0800
|
|
||||||
Subject: [PATCH 09/36] Revert "vfio/pci: Implement return_page_response page
|
|
||||||
response callback"
|
|
||||||
|
|
||||||
This reverts commit 6bbf810edebdb89a6958519ee3adfb1888520231.
|
|
||||||
|
|
||||||
Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com>
|
|
||||||
---
|
|
||||||
hw/vfio/pci.c | 123 --------------------------------------------------
|
|
||||||
hw/vfio/pci.h | 2 -
|
|
||||||
2 files changed, 125 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
|
|
||||||
index 8e24f9c7d1..c54e62fe8f 100644
|
|
||||||
--- a/hw/vfio/pci.c
|
|
||||||
+++ b/hw/vfio/pci.c
|
|
||||||
@@ -2693,61 +2693,6 @@ out:
|
|
||||||
g_free(fault_region_info);
|
|
||||||
}
|
|
||||||
|
|
||||||
-static void vfio_init_fault_response_regions(VFIOPCIDevice *vdev, Error **errp)
|
|
||||||
-{
|
|
||||||
- struct vfio_region_info *fault_region_info = NULL;
|
|
||||||
- struct vfio_region_info_cap_fault *cap_fault;
|
|
||||||
- VFIODevice *vbasedev = &vdev->vbasedev;
|
|
||||||
- struct vfio_info_cap_header *hdr;
|
|
||||||
- char *fault_region_name;
|
|
||||||
- int ret;
|
|
||||||
-
|
|
||||||
- ret = vfio_get_dev_region_info(&vdev->vbasedev,
|
|
||||||
- VFIO_REGION_TYPE_NESTED,
|
|
||||||
- VFIO_REGION_SUBTYPE_NESTED_DMA_FAULT_RESPONSE,
|
|
||||||
- &fault_region_info);
|
|
||||||
- if (ret) {
|
|
||||||
- goto out;
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
- hdr = vfio_get_region_info_cap(fault_region_info,
|
|
||||||
- VFIO_REGION_INFO_CAP_DMA_FAULT_RESPONSE);
|
|
||||||
- if (!hdr) {
|
|
||||||
- error_setg(errp, "failed to retrieve DMA FAULT RESPONSE capability");
|
|
||||||
- goto out;
|
|
||||||
- }
|
|
||||||
- cap_fault = container_of(hdr, struct vfio_region_info_cap_fault,
|
|
||||||
- header);
|
|
||||||
- if (cap_fault->version != 1) {
|
|
||||||
- error_setg(errp, "Unsupported DMA FAULT RESPONSE API version %d",
|
|
||||||
- cap_fault->version);
|
|
||||||
- goto out;
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
- fault_region_name = g_strdup_printf("%s DMA FAULT RESPONSE %d",
|
|
||||||
- vbasedev->name,
|
|
||||||
- fault_region_info->index);
|
|
||||||
-
|
|
||||||
- ret = vfio_region_setup(OBJECT(vdev), vbasedev,
|
|
||||||
- &vdev->dma_fault_response_region,
|
|
||||||
- fault_region_info->index,
|
|
||||||
- fault_region_name);
|
|
||||||
- g_free(fault_region_name);
|
|
||||||
- if (ret) {
|
|
||||||
- error_setg_errno(errp, -ret,
|
|
||||||
- "failed to set up the DMA FAULT RESPONSE region %d",
|
|
||||||
- fault_region_info->index);
|
|
||||||
- goto out;
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
- ret = vfio_region_mmap(&vdev->dma_fault_response_region);
|
|
||||||
- if (ret) {
|
|
||||||
- error_setg_errno(errp, -ret, "Failed to mmap the DMA FAULT RESPONSE queue");
|
|
||||||
- }
|
|
||||||
-out:
|
|
||||||
- g_free(fault_region_info);
|
|
||||||
-}
|
|
||||||
-
|
|
||||||
static void vfio_populate_device(VFIOPCIDevice *vdev, Error **errp)
|
|
||||||
{
|
|
||||||
VFIODevice *vbasedev = &vdev->vbasedev;
|
|
||||||
@@ -2823,12 +2768,6 @@ static void vfio_populate_device(VFIOPCIDevice *vdev, Error **errp)
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
- vfio_init_fault_response_regions(vdev, &err);
|
|
||||||
- if (err) {
|
|
||||||
- error_propagate(errp, err);
|
|
||||||
- return;
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
irq_info.index = VFIO_PCI_ERR_IRQ_INDEX;
|
|
||||||
|
|
||||||
ret = ioctl(vdev->vbasedev.fd, VFIO_DEVICE_GET_IRQ_INFO, &irq_info);
|
|
||||||
@@ -3007,68 +2946,8 @@ static int vfio_iommu_set_pasid_table(PCIBus *bus, int32_t devfn,
|
|
||||||
return ioctl(container->fd, VFIO_IOMMU_SET_PASID_TABLE, &info);
|
|
||||||
}
|
|
||||||
|
|
||||||
-static int vfio_iommu_return_page_response(PCIBus *bus, int32_t devfn,
|
|
||||||
- IOMMUPageResponse *resp)
|
|
||||||
-{
|
|
||||||
- PCIDevice *pdev = bus->devices[devfn];
|
|
||||||
- VFIOPCIDevice *vdev = DO_UPCAST(VFIOPCIDevice, pdev, pdev);
|
|
||||||
- struct iommu_page_response *response = &resp->resp;
|
|
||||||
- struct vfio_region_dma_fault_response header;
|
|
||||||
- struct iommu_page_response *queue;
|
|
||||||
- char *queue_buffer = NULL;
|
|
||||||
- ssize_t bytes;
|
|
||||||
-
|
|
||||||
- if (!vdev->dma_fault_response_region.mem) {
|
|
||||||
- return -EINVAL;
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
- /* read the header */
|
|
||||||
- bytes = pread(vdev->vbasedev.fd, &header, sizeof(header),
|
|
||||||
- vdev->dma_fault_response_region.fd_offset);
|
|
||||||
- if (bytes != sizeof(header)) {
|
|
||||||
- error_report("%s unable to read the fault region header (0x%lx)",
|
|
||||||
- __func__, bytes);
|
|
||||||
- return -1;
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
- /* Normally the fault queue is mmapped */
|
|
||||||
- queue = (struct iommu_page_response *)vdev->dma_fault_response_region.mmaps[0].mmap;
|
|
||||||
- if (!queue) {
|
|
||||||
- size_t queue_size = header.nb_entries * header.entry_size;
|
|
||||||
-
|
|
||||||
- error_report("%s: fault queue not mmapped: slower fault handling",
|
|
||||||
- vdev->vbasedev.name);
|
|
||||||
-
|
|
||||||
- queue_buffer = g_malloc(queue_size);
|
|
||||||
- bytes = pread(vdev->vbasedev.fd, queue_buffer, queue_size,
|
|
||||||
- vdev->dma_fault_response_region.fd_offset + header.offset);
|
|
||||||
- if (bytes != queue_size) {
|
|
||||||
- error_report("%s unable to read the fault queue (0x%lx)",
|
|
||||||
- __func__, bytes);
|
|
||||||
- return -1;
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
- queue = (struct iommu_page_response *)queue_buffer;
|
|
||||||
- }
|
|
||||||
- /* deposit the new response in the queue and increment the head */
|
|
||||||
- memcpy(queue + header.head, response, header.entry_size);
|
|
||||||
-
|
|
||||||
- vdev->fault_response_head_index =
|
|
||||||
- (vdev->fault_response_head_index + 1) % header.nb_entries;
|
|
||||||
- bytes = pwrite(vdev->vbasedev.fd, &vdev->fault_response_head_index, 4,
|
|
||||||
- vdev->dma_fault_response_region.fd_offset);
|
|
||||||
- if (bytes != 4) {
|
|
||||||
- error_report("%s unable to write the fault response region head index (0x%lx)",
|
|
||||||
- __func__, bytes);
|
|
||||||
- }
|
|
||||||
- g_free(queue_buffer);
|
|
||||||
-
|
|
||||||
- return 0;
|
|
||||||
-}
|
|
||||||
-
|
|
||||||
static PCIPASIDOps vfio_pci_pasid_ops = {
|
|
||||||
.set_pasid_table = vfio_iommu_set_pasid_table,
|
|
||||||
- .return_page_response = vfio_iommu_return_page_response,
|
|
||||||
};
|
|
||||||
|
|
||||||
static void vfio_dma_fault_notifier_handler(void *opaque)
|
|
||||||
@@ -3532,7 +3411,6 @@ static void vfio_instance_finalize(Object *obj)
|
|
||||||
vfio_display_finalize(vdev);
|
|
||||||
vfio_bars_finalize(vdev);
|
|
||||||
vfio_region_finalize(&vdev->dma_fault_region);
|
|
||||||
- vfio_region_finalize(&vdev->dma_fault_response_region);
|
|
||||||
g_free(vdev->emulated_config_bits);
|
|
||||||
g_free(vdev->rom);
|
|
||||||
/*
|
|
||||||
@@ -3554,7 +3432,6 @@ static void vfio_exitfn(PCIDevice *pdev)
|
|
||||||
vfio_unregister_err_notifier(vdev);
|
|
||||||
vfio_unregister_ext_irq_notifiers(vdev);
|
|
||||||
vfio_region_exit(&vdev->dma_fault_region);
|
|
||||||
- vfio_region_exit(&vdev->dma_fault_response_region);
|
|
||||||
pci_device_set_intx_routing_notifier(&vdev->pdev, NULL);
|
|
||||||
if (vdev->irqchip_change_notifier.notify) {
|
|
||||||
kvm_irqchip_remove_change_notifier(&vdev->irqchip_change_notifier);
|
|
||||||
diff --git a/hw/vfio/pci.h b/hw/vfio/pci.h
|
|
||||||
index 61b3bf1303..03ac8919ef 100644
|
|
||||||
--- a/hw/vfio/pci.h
|
|
||||||
+++ b/hw/vfio/pci.h
|
|
||||||
@@ -147,8 +147,6 @@ struct VFIOPCIDevice {
|
|
||||||
VFIOPCIExtIRQ *ext_irqs;
|
|
||||||
VFIORegion dma_fault_region;
|
|
||||||
uint32_t fault_tail_index;
|
|
||||||
- VFIORegion dma_fault_response_region;
|
|
||||||
- uint32_t fault_response_head_index;
|
|
||||||
int (*resetfn)(struct VFIOPCIDevice *);
|
|
||||||
uint32_t vendor_id;
|
|
||||||
uint32_t device_id;
|
|
||||||
--
|
|
||||||
2.27.0
|
|
||||||
|
|
||||||
@ -1,93 +0,0 @@
|
|||||||
From 013220b686022a2e4ddb6a3d50af467275d25070 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Kunkun Jiang <jiangkunkun@huawei.com>
|
|
||||||
Date: Fri, 18 Nov 2022 15:22:37 +0800
|
|
||||||
Subject: [PATCH 18/36] Revert "vfio/pci: Implement the DMA fault handler"
|
|
||||||
|
|
||||||
This reverts commit d33cc7eccb68c6a1488804c94ff5c1197ee0fc6e.
|
|
||||||
|
|
||||||
Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com>
|
|
||||||
---
|
|
||||||
hw/vfio/pci.c | 50 --------------------------------------------------
|
|
||||||
hw/vfio/pci.h | 1 -
|
|
||||||
2 files changed, 51 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
|
|
||||||
index c54e62fe8f..76bc9d3506 100644
|
|
||||||
--- a/hw/vfio/pci.c
|
|
||||||
+++ b/hw/vfio/pci.c
|
|
||||||
@@ -2953,60 +2953,10 @@ static PCIPASIDOps vfio_pci_pasid_ops = {
|
|
||||||
static void vfio_dma_fault_notifier_handler(void *opaque)
|
|
||||||
{
|
|
||||||
VFIOPCIExtIRQ *ext_irq = opaque;
|
|
||||||
- VFIOPCIDevice *vdev = ext_irq->vdev;
|
|
||||||
- PCIDevice *pdev = &vdev->pdev;
|
|
||||||
- AddressSpace *as = pci_device_iommu_address_space(pdev);
|
|
||||||
- IOMMUMemoryRegion *iommu_mr = IOMMU_MEMORY_REGION(as->root);
|
|
||||||
- struct vfio_region_dma_fault header;
|
|
||||||
- struct iommu_fault *queue;
|
|
||||||
- char *queue_buffer = NULL;
|
|
||||||
- ssize_t bytes;
|
|
||||||
|
|
||||||
if (!event_notifier_test_and_clear(&ext_irq->notifier)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
-
|
|
||||||
- bytes = pread(vdev->vbasedev.fd, &header, sizeof(header),
|
|
||||||
- vdev->dma_fault_region.fd_offset);
|
|
||||||
- if (bytes != sizeof(header)) {
|
|
||||||
- error_report("%s unable to read the fault region header (0x%lx)",
|
|
||||||
- __func__, bytes);
|
|
||||||
- return;
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
- /* Normally the fault queue is mmapped */
|
|
||||||
- queue = (struct iommu_fault *)vdev->dma_fault_region.mmaps[0].mmap;
|
|
||||||
- if (!queue) {
|
|
||||||
- size_t queue_size = header.nb_entries * header.entry_size;
|
|
||||||
-
|
|
||||||
- error_report("%s: fault queue not mmapped: slower fault handling",
|
|
||||||
- vdev->vbasedev.name);
|
|
||||||
-
|
|
||||||
- queue_buffer = g_malloc(queue_size);
|
|
||||||
- bytes = pread(vdev->vbasedev.fd, queue_buffer, queue_size,
|
|
||||||
- vdev->dma_fault_region.fd_offset + header.offset);
|
|
||||||
- if (bytes != queue_size) {
|
|
||||||
- error_report("%s unable to read the fault queue (0x%lx)",
|
|
||||||
- __func__, bytes);
|
|
||||||
- return;
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
- queue = (struct iommu_fault *)queue_buffer;
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
- while (vdev->fault_tail_index != header.head) {
|
|
||||||
- memory_region_inject_faults(iommu_mr, 1,
|
|
||||||
- &queue[vdev->fault_tail_index]);
|
|
||||||
- vdev->fault_tail_index =
|
|
||||||
- (vdev->fault_tail_index + 1) % header.nb_entries;
|
|
||||||
- }
|
|
||||||
- bytes = pwrite(vdev->vbasedev.fd, &vdev->fault_tail_index, 4,
|
|
||||||
- vdev->dma_fault_region.fd_offset);
|
|
||||||
- if (bytes != 4) {
|
|
||||||
- error_report("%s unable to write the fault region tail index (0x%lx)",
|
|
||||||
- __func__, bytes);
|
|
||||||
- }
|
|
||||||
- g_free(queue_buffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int vfio_register_ext_irq_handler(VFIOPCIDevice *vdev,
|
|
||||||
diff --git a/hw/vfio/pci.h b/hw/vfio/pci.h
|
|
||||||
index 03ac8919ef..eef91065f1 100644
|
|
||||||
--- a/hw/vfio/pci.h
|
|
||||||
+++ b/hw/vfio/pci.h
|
|
||||||
@@ -146,7 +146,6 @@ struct VFIOPCIDevice {
|
|
||||||
EventNotifier req_notifier;
|
|
||||||
VFIOPCIExtIRQ *ext_irqs;
|
|
||||||
VFIORegion dma_fault_region;
|
|
||||||
- uint32_t fault_tail_index;
|
|
||||||
int (*resetfn)(struct VFIOPCIDevice *);
|
|
||||||
uint32_t vendor_id;
|
|
||||||
uint32_t device_id;
|
|
||||||
--
|
|
||||||
2.27.0
|
|
||||||
|
|
||||||
@ -1,161 +0,0 @@
|
|||||||
From f32fc48313dadeb6469c00660bd96331e120030f Mon Sep 17 00:00:00 2001
|
|
||||||
From: Kunkun Jiang <jiangkunkun@huawei.com>
|
|
||||||
Date: Fri, 18 Nov 2022 15:22:40 +0800
|
|
||||||
Subject: [PATCH 20/36] Revert "vfio/pci: Register handler for iommu fault"
|
|
||||||
|
|
||||||
This reverts commit 574455d1363e818905e05cd23ef0948e83a16a51.
|
|
||||||
|
|
||||||
Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com>
|
|
||||||
---
|
|
||||||
hw/vfio/pci.c | 81 +--------------------------------------------------
|
|
||||||
hw/vfio/pci.h | 7 -----
|
|
||||||
2 files changed, 1 insertion(+), 87 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
|
|
||||||
index 37a70932c6..99c52a0944 100644
|
|
||||||
--- a/hw/vfio/pci.c
|
|
||||||
+++ b/hw/vfio/pci.c
|
|
||||||
@@ -2888,76 +2888,6 @@ static PCIPASIDOps vfio_pci_pasid_ops = {
|
|
||||||
.set_pasid_table = vfio_iommu_set_pasid_table,
|
|
||||||
};
|
|
||||||
|
|
||||||
-static void vfio_dma_fault_notifier_handler(void *opaque)
|
|
||||||
-{
|
|
||||||
- VFIOPCIExtIRQ *ext_irq = opaque;
|
|
||||||
-
|
|
||||||
- if (!event_notifier_test_and_clear(&ext_irq->notifier)) {
|
|
||||||
- return;
|
|
||||||
- }
|
|
||||||
-}
|
|
||||||
-
|
|
||||||
-static int vfio_register_ext_irq_handler(VFIOPCIDevice *vdev,
|
|
||||||
- uint32_t type, uint32_t subtype,
|
|
||||||
- IOHandler *handler)
|
|
||||||
-{
|
|
||||||
- int32_t fd, ext_irq_index, index;
|
|
||||||
- struct vfio_irq_info *irq_info;
|
|
||||||
- Error *err = NULL;
|
|
||||||
- EventNotifier *n;
|
|
||||||
- int ret;
|
|
||||||
-
|
|
||||||
- ret = vfio_get_dev_irq_info(&vdev->vbasedev, type, subtype, &irq_info);
|
|
||||||
- if (ret) {
|
|
||||||
- return ret;
|
|
||||||
- }
|
|
||||||
- index = irq_info->index;
|
|
||||||
- ext_irq_index = irq_info->index - VFIO_PCI_NUM_IRQS;
|
|
||||||
- g_free(irq_info);
|
|
||||||
-
|
|
||||||
- vdev->ext_irqs[ext_irq_index].vdev = vdev;
|
|
||||||
- vdev->ext_irqs[ext_irq_index].index = index;
|
|
||||||
- n = &vdev->ext_irqs[ext_irq_index].notifier;
|
|
||||||
-
|
|
||||||
- ret = event_notifier_init(n, 0);
|
|
||||||
- if (ret) {
|
|
||||||
- error_report("vfio: Unable to init event notifier for ext irq %d(%d)",
|
|
||||||
- ext_irq_index, ret);
|
|
||||||
- return ret;
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
- fd = event_notifier_get_fd(n);
|
|
||||||
- qemu_set_fd_handler(fd, vfio_dma_fault_notifier_handler, NULL,
|
|
||||||
- &vdev->ext_irqs[ext_irq_index]);
|
|
||||||
-
|
|
||||||
- ret = vfio_set_irq_signaling(&vdev->vbasedev, index, 0,
|
|
||||||
- VFIO_IRQ_SET_ACTION_TRIGGER, fd, &err);
|
|
||||||
- if (ret) {
|
|
||||||
- error_reportf_err(err, VFIO_MSG_PREFIX, vdev->vbasedev.name);
|
|
||||||
- qemu_set_fd_handler(fd, NULL, NULL, vdev);
|
|
||||||
- event_notifier_cleanup(n);
|
|
||||||
- }
|
|
||||||
- return ret;
|
|
||||||
-}
|
|
||||||
-
|
|
||||||
-static void vfio_unregister_ext_irq_notifiers(VFIOPCIDevice *vdev)
|
|
||||||
-{
|
|
||||||
- VFIODevice *vbasedev = &vdev->vbasedev;
|
|
||||||
- Error *err = NULL;
|
|
||||||
- int i;
|
|
||||||
-
|
|
||||||
- for (i = 0; i < vbasedev->num_irqs - VFIO_PCI_NUM_IRQS; i++) {
|
|
||||||
- if (vfio_set_irq_signaling(vbasedev, i + VFIO_PCI_NUM_IRQS , 0,
|
|
||||||
- VFIO_IRQ_SET_ACTION_TRIGGER, -1, &err)) {
|
|
||||||
- error_reportf_err(err, VFIO_MSG_PREFIX, vdev->vbasedev.name);
|
|
||||||
- }
|
|
||||||
- qemu_set_fd_handler(event_notifier_get_fd(&vdev->ext_irqs[i].notifier),
|
|
||||||
- NULL, NULL, vdev);
|
|
||||||
- event_notifier_cleanup(&vdev->ext_irqs[i].notifier);
|
|
||||||
- }
|
|
||||||
- g_free(vdev->ext_irqs);
|
|
||||||
-}
|
|
||||||
-
|
|
||||||
static void vfio_realize(PCIDevice *pdev, Error **errp)
|
|
||||||
{
|
|
||||||
VFIOPCIDevice *vdev = VFIO_PCI(pdev);
|
|
||||||
@@ -2968,7 +2898,7 @@ static void vfio_realize(PCIDevice *pdev, Error **errp)
|
|
||||||
ssize_t len;
|
|
||||||
struct stat st;
|
|
||||||
int groupid;
|
|
||||||
- int i, ret, nb_ext_irqs;
|
|
||||||
+ int i, ret;
|
|
||||||
bool is_mdev;
|
|
||||||
|
|
||||||
if (!vdev->vbasedev.sysfsdev) {
|
|
||||||
@@ -3056,11 +2986,6 @@ static void vfio_realize(PCIDevice *pdev, Error **errp)
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
|
|
||||||
- nb_ext_irqs = vdev->vbasedev.num_irqs - VFIO_PCI_NUM_IRQS;
|
|
||||||
- if (nb_ext_irqs > 0) {
|
|
||||||
- vdev->ext_irqs = g_new0(VFIOPCIExtIRQ, nb_ext_irqs);
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
vfio_populate_device(vdev, &err);
|
|
||||||
if (err) {
|
|
||||||
error_propagate(errp, err);
|
|
||||||
@@ -3272,9 +3197,6 @@ static void vfio_realize(PCIDevice *pdev, Error **errp)
|
|
||||||
|
|
||||||
vfio_register_err_notifier(vdev);
|
|
||||||
vfio_register_req_notifier(vdev);
|
|
||||||
- vfio_register_ext_irq_handler(vdev, VFIO_IRQ_TYPE_NESTED,
|
|
||||||
- VFIO_IRQ_SUBTYPE_DMA_FAULT,
|
|
||||||
- vfio_dma_fault_notifier_handler);
|
|
||||||
vfio_setup_resetfn_quirk(vdev);
|
|
||||||
|
|
||||||
pci_setup_pasid_ops(pdev, &vfio_pci_pasid_ops);
|
|
||||||
@@ -3317,7 +3239,6 @@ static void vfio_exitfn(PCIDevice *pdev)
|
|
||||||
|
|
||||||
vfio_unregister_req_notifier(vdev);
|
|
||||||
vfio_unregister_err_notifier(vdev);
|
|
||||||
- vfio_unregister_ext_irq_notifiers(vdev);
|
|
||||||
pci_device_set_intx_routing_notifier(&vdev->pdev, NULL);
|
|
||||||
if (vdev->irqchip_change_notifier.notify) {
|
|
||||||
kvm_irqchip_remove_change_notifier(&vdev->irqchip_change_notifier);
|
|
||||||
diff --git a/hw/vfio/pci.h b/hw/vfio/pci.h
|
|
||||||
index a8b06737fb..64777516d1 100644
|
|
||||||
--- a/hw/vfio/pci.h
|
|
||||||
+++ b/hw/vfio/pci.h
|
|
||||||
@@ -114,12 +114,6 @@ typedef struct VFIOMSIXInfo {
|
|
||||||
unsigned long *pending;
|
|
||||||
} VFIOMSIXInfo;
|
|
||||||
|
|
||||||
-typedef struct VFIOPCIExtIRQ {
|
|
||||||
- struct VFIOPCIDevice *vdev;
|
|
||||||
- EventNotifier notifier;
|
|
||||||
- uint32_t index;
|
|
||||||
-} VFIOPCIExtIRQ;
|
|
||||||
-
|
|
||||||
#define TYPE_VFIO_PCI "vfio-pci"
|
|
||||||
OBJECT_DECLARE_SIMPLE_TYPE(VFIOPCIDevice, VFIO_PCI)
|
|
||||||
|
|
||||||
@@ -144,7 +138,6 @@ struct VFIOPCIDevice {
|
|
||||||
PCIHostDeviceAddress host;
|
|
||||||
EventNotifier err_notifier;
|
|
||||||
EventNotifier req_notifier;
|
|
||||||
- VFIOPCIExtIRQ *ext_irqs;
|
|
||||||
int (*resetfn)(struct VFIOPCIDevice *);
|
|
||||||
uint32_t vendor_id;
|
|
||||||
uint32_t device_id;
|
|
||||||
--
|
|
||||||
2.27.0
|
|
||||||
|
|
||||||
@ -1,129 +0,0 @@
|
|||||||
From 0e9cc7c0a60ace8baeab6e32f49770afbeec6f5d Mon Sep 17 00:00:00 2001
|
|
||||||
From: Kunkun Jiang <jiangkunkun@huawei.com>
|
|
||||||
Date: Fri, 18 Nov 2022 15:22:38 +0800
|
|
||||||
Subject: [PATCH 19/36] Revert "vfio/pci: Set up the DMA FAULT region"
|
|
||||||
|
|
||||||
This reverts commit e701d0fef4fbb7935d6aa7d22d82eb2dcfee2431.
|
|
||||||
|
|
||||||
Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com>
|
|
||||||
---
|
|
||||||
hw/vfio/pci.c | 64 ---------------------------------------------------
|
|
||||||
hw/vfio/pci.h | 1 -
|
|
||||||
2 files changed, 65 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
|
|
||||||
index 76bc9d3506..37a70932c6 100644
|
|
||||||
--- a/hw/vfio/pci.c
|
|
||||||
+++ b/hw/vfio/pci.c
|
|
||||||
@@ -2638,67 +2638,11 @@ int vfio_populate_vga(VFIOPCIDevice *vdev, Error **errp)
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
-static void vfio_init_fault_regions(VFIOPCIDevice *vdev, Error **errp)
|
|
||||||
-{
|
|
||||||
- struct vfio_region_info *fault_region_info = NULL;
|
|
||||||
- struct vfio_region_info_cap_fault *cap_fault;
|
|
||||||
- VFIODevice *vbasedev = &vdev->vbasedev;
|
|
||||||
- struct vfio_info_cap_header *hdr;
|
|
||||||
- char *fault_region_name;
|
|
||||||
- int ret;
|
|
||||||
-
|
|
||||||
- ret = vfio_get_dev_region_info(&vdev->vbasedev,
|
|
||||||
- VFIO_REGION_TYPE_NESTED,
|
|
||||||
- VFIO_REGION_SUBTYPE_NESTED_DMA_FAULT,
|
|
||||||
- &fault_region_info);
|
|
||||||
- if (ret) {
|
|
||||||
- goto out;
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
- hdr = vfio_get_region_info_cap(fault_region_info,
|
|
||||||
- VFIO_REGION_INFO_CAP_DMA_FAULT);
|
|
||||||
- if (!hdr) {
|
|
||||||
- error_setg(errp, "failed to retrieve DMA FAULT capability");
|
|
||||||
- goto out;
|
|
||||||
- }
|
|
||||||
- cap_fault = container_of(hdr, struct vfio_region_info_cap_fault,
|
|
||||||
- header);
|
|
||||||
- if (cap_fault->version != 1) {
|
|
||||||
- error_setg(errp, "Unsupported DMA FAULT API version %d",
|
|
||||||
- cap_fault->version);
|
|
||||||
- goto out;
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
- fault_region_name = g_strdup_printf("%s DMA FAULT %d",
|
|
||||||
- vbasedev->name,
|
|
||||||
- fault_region_info->index);
|
|
||||||
-
|
|
||||||
- ret = vfio_region_setup(OBJECT(vdev), vbasedev,
|
|
||||||
- &vdev->dma_fault_region,
|
|
||||||
- fault_region_info->index,
|
|
||||||
- fault_region_name);
|
|
||||||
- g_free(fault_region_name);
|
|
||||||
- if (ret) {
|
|
||||||
- error_setg_errno(errp, -ret,
|
|
||||||
- "failed to set up the DMA FAULT region %d",
|
|
||||||
- fault_region_info->index);
|
|
||||||
- goto out;
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
- ret = vfio_region_mmap(&vdev->dma_fault_region);
|
|
||||||
- if (ret) {
|
|
||||||
- error_setg_errno(errp, -ret, "Failed to mmap the DMA FAULT queue");
|
|
||||||
- }
|
|
||||||
-out:
|
|
||||||
- g_free(fault_region_info);
|
|
||||||
-}
|
|
||||||
-
|
|
||||||
static void vfio_populate_device(VFIOPCIDevice *vdev, Error **errp)
|
|
||||||
{
|
|
||||||
VFIODevice *vbasedev = &vdev->vbasedev;
|
|
||||||
struct vfio_region_info *reg_info;
|
|
||||||
struct vfio_irq_info irq_info = { .argsz = sizeof(irq_info) };
|
|
||||||
- Error *err = NULL;
|
|
||||||
int i, ret = -1;
|
|
||||||
|
|
||||||
/* Sanity check device */
|
|
||||||
@@ -2762,12 +2706,6 @@ static void vfio_populate_device(VFIOPCIDevice *vdev, Error **errp)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
- vfio_init_fault_regions(vdev, &err);
|
|
||||||
- if (err) {
|
|
||||||
- error_propagate(errp, err);
|
|
||||||
- return;
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
irq_info.index = VFIO_PCI_ERR_IRQ_INDEX;
|
|
||||||
|
|
||||||
ret = ioctl(vdev->vbasedev.fd, VFIO_DEVICE_GET_IRQ_INFO, &irq_info);
|
|
||||||
@@ -3360,7 +3298,6 @@ static void vfio_instance_finalize(Object *obj)
|
|
||||||
|
|
||||||
vfio_display_finalize(vdev);
|
|
||||||
vfio_bars_finalize(vdev);
|
|
||||||
- vfio_region_finalize(&vdev->dma_fault_region);
|
|
||||||
g_free(vdev->emulated_config_bits);
|
|
||||||
g_free(vdev->rom);
|
|
||||||
/*
|
|
||||||
@@ -3381,7 +3318,6 @@ static void vfio_exitfn(PCIDevice *pdev)
|
|
||||||
vfio_unregister_req_notifier(vdev);
|
|
||||||
vfio_unregister_err_notifier(vdev);
|
|
||||||
vfio_unregister_ext_irq_notifiers(vdev);
|
|
||||||
- vfio_region_exit(&vdev->dma_fault_region);
|
|
||||||
pci_device_set_intx_routing_notifier(&vdev->pdev, NULL);
|
|
||||||
if (vdev->irqchip_change_notifier.notify) {
|
|
||||||
kvm_irqchip_remove_change_notifier(&vdev->irqchip_change_notifier);
|
|
||||||
diff --git a/hw/vfio/pci.h b/hw/vfio/pci.h
|
|
||||||
index eef91065f1..a8b06737fb 100644
|
|
||||||
--- a/hw/vfio/pci.h
|
|
||||||
+++ b/hw/vfio/pci.h
|
|
||||||
@@ -145,7 +145,6 @@ struct VFIOPCIDevice {
|
|
||||||
EventNotifier err_notifier;
|
|
||||||
EventNotifier req_notifier;
|
|
||||||
VFIOPCIExtIRQ *ext_irqs;
|
|
||||||
- VFIORegion dma_fault_region;
|
|
||||||
int (*resetfn)(struct VFIOPCIDevice *);
|
|
||||||
uint32_t vendor_id;
|
|
||||||
uint32_t device_id;
|
|
||||||
--
|
|
||||||
2.27.0
|
|
||||||
|
|
||||||
@ -1,703 +0,0 @@
|
|||||||
From d3b9b26c9bb53b00b1441b3edad446ffea1ad8ff Mon Sep 17 00:00:00 2001
|
|
||||||
From: Kunkun Jiang <jiangkunkun@huawei.com>
|
|
||||||
Date: Fri, 18 Nov 2022 15:22:58 +0800
|
|
||||||
Subject: [PATCH 35/36] Revert "vfio.h and iommu.h header update against 5.10"
|
|
||||||
|
|
||||||
This reverts commit 36b65d7312a343cb636e6963b8262dce9420ebc6.
|
|
||||||
|
|
||||||
Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com>
|
|
||||||
---
|
|
||||||
linux-headers/linux/iommu.h | 395 ------------------------------------
|
|
||||||
linux-headers/linux/vfio.h | 220 +-------------------
|
|
||||||
2 files changed, 2 insertions(+), 613 deletions(-)
|
|
||||||
delete mode 100644 linux-headers/linux/iommu.h
|
|
||||||
|
|
||||||
diff --git a/linux-headers/linux/iommu.h b/linux-headers/linux/iommu.h
|
|
||||||
deleted file mode 100644
|
|
||||||
index 773b7dc2d6..0000000000
|
|
||||||
--- a/linux-headers/linux/iommu.h
|
|
||||||
+++ /dev/null
|
|
||||||
@@ -1,395 +0,0 @@
|
|
||||||
-/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
|
|
||||||
-/*
|
|
||||||
- * IOMMU user API definitions
|
|
||||||
- */
|
|
||||||
-
|
|
||||||
-#ifndef IOMMU_H
|
|
||||||
-#define IOMMU_H
|
|
||||||
-
|
|
||||||
-#include <linux/types.h>
|
|
||||||
-
|
|
||||||
-#define IOMMU_FAULT_PERM_READ (1 << 0) /* read */
|
|
||||||
-#define IOMMU_FAULT_PERM_WRITE (1 << 1) /* write */
|
|
||||||
-#define IOMMU_FAULT_PERM_EXEC (1 << 2) /* exec */
|
|
||||||
-#define IOMMU_FAULT_PERM_PRIV (1 << 3) /* privileged */
|
|
||||||
-
|
|
||||||
-/* Generic fault types, can be expanded IRQ remapping fault */
|
|
||||||
-enum iommu_fault_type {
|
|
||||||
- IOMMU_FAULT_DMA_UNRECOV = 1, /* unrecoverable fault */
|
|
||||||
- IOMMU_FAULT_PAGE_REQ, /* page request fault */
|
|
||||||
-};
|
|
||||||
-
|
|
||||||
-enum iommu_fault_reason {
|
|
||||||
- IOMMU_FAULT_REASON_UNKNOWN = 0,
|
|
||||||
-
|
|
||||||
- /* Could not access the PASID table (fetch caused external abort) */
|
|
||||||
- IOMMU_FAULT_REASON_PASID_FETCH,
|
|
||||||
-
|
|
||||||
- /* PASID entry is invalid or has configuration errors */
|
|
||||||
- IOMMU_FAULT_REASON_BAD_PASID_ENTRY,
|
|
||||||
-
|
|
||||||
- /*
|
|
||||||
- * PASID is out of range (e.g. exceeds the maximum PASID
|
|
||||||
- * supported by the IOMMU) or disabled.
|
|
||||||
- */
|
|
||||||
- IOMMU_FAULT_REASON_PASID_INVALID,
|
|
||||||
-
|
|
||||||
- /*
|
|
||||||
- * An external abort occurred fetching (or updating) a translation
|
|
||||||
- * table descriptor
|
|
||||||
- */
|
|
||||||
- IOMMU_FAULT_REASON_WALK_EABT,
|
|
||||||
-
|
|
||||||
- /*
|
|
||||||
- * Could not access the page table entry (Bad address),
|
|
||||||
- * actual translation fault
|
|
||||||
- */
|
|
||||||
- IOMMU_FAULT_REASON_PTE_FETCH,
|
|
||||||
-
|
|
||||||
- /* Protection flag check failed */
|
|
||||||
- IOMMU_FAULT_REASON_PERMISSION,
|
|
||||||
-
|
|
||||||
- /* access flag check failed */
|
|
||||||
- IOMMU_FAULT_REASON_ACCESS,
|
|
||||||
-
|
|
||||||
- /* Output address of a translation stage caused Address Size fault */
|
|
||||||
- IOMMU_FAULT_REASON_OOR_ADDRESS,
|
|
||||||
-};
|
|
||||||
-
|
|
||||||
-/**
|
|
||||||
- * struct iommu_fault_unrecoverable - Unrecoverable fault data
|
|
||||||
- * @reason: reason of the fault, from &enum iommu_fault_reason
|
|
||||||
- * @flags: parameters of this fault (IOMMU_FAULT_UNRECOV_* values)
|
|
||||||
- * @pasid: Process Address Space ID
|
|
||||||
- * @perm: requested permission access using by the incoming transaction
|
|
||||||
- * (IOMMU_FAULT_PERM_* values)
|
|
||||||
- * @addr: offending page address
|
|
||||||
- * @fetch_addr: address that caused a fetch abort, if any
|
|
||||||
- */
|
|
||||||
-struct iommu_fault_unrecoverable {
|
|
||||||
- __u32 reason;
|
|
||||||
-#define IOMMU_FAULT_UNRECOV_PASID_VALID (1 << 0)
|
|
||||||
-#define IOMMU_FAULT_UNRECOV_ADDR_VALID (1 << 1)
|
|
||||||
-#define IOMMU_FAULT_UNRECOV_FETCH_ADDR_VALID (1 << 2)
|
|
||||||
- __u32 flags;
|
|
||||||
- __u32 pasid;
|
|
||||||
- __u32 perm;
|
|
||||||
- __u64 addr;
|
|
||||||
- __u64 fetch_addr;
|
|
||||||
-};
|
|
||||||
-
|
|
||||||
-/**
|
|
||||||
- * struct iommu_fault_page_request - Page Request data
|
|
||||||
- * @flags: encodes whether the corresponding fields are valid and whether this
|
|
||||||
- * is the last page in group (IOMMU_FAULT_PAGE_REQUEST_* values).
|
|
||||||
- * When IOMMU_FAULT_PAGE_RESPONSE_NEEDS_PASID is set, the page response
|
|
||||||
- * must have the same PASID value as the page request. When it is clear,
|
|
||||||
- * the page response should not have a PASID.
|
|
||||||
- * @pasid: Process Address Space ID
|
|
||||||
- * @grpid: Page Request Group Index
|
|
||||||
- * @perm: requested page permissions (IOMMU_FAULT_PERM_* values)
|
|
||||||
- * @addr: page address
|
|
||||||
- * @private_data: device-specific private information
|
|
||||||
- */
|
|
||||||
-struct iommu_fault_page_request {
|
|
||||||
-#define IOMMU_FAULT_PAGE_REQUEST_PASID_VALID (1 << 0)
|
|
||||||
-#define IOMMU_FAULT_PAGE_REQUEST_LAST_PAGE (1 << 1)
|
|
||||||
-#define IOMMU_FAULT_PAGE_REQUEST_PRIV_DATA (1 << 2)
|
|
||||||
-#define IOMMU_FAULT_PAGE_RESPONSE_NEEDS_PASID (1 << 3)
|
|
||||||
- __u32 flags;
|
|
||||||
- __u32 pasid;
|
|
||||||
- __u32 grpid;
|
|
||||||
- __u32 perm;
|
|
||||||
- __u64 addr;
|
|
||||||
- __u64 private_data[2];
|
|
||||||
-};
|
|
||||||
-
|
|
||||||
-/**
|
|
||||||
- * struct iommu_fault - Generic fault data
|
|
||||||
- * @type: fault type from &enum iommu_fault_type
|
|
||||||
- * @padding: reserved for future use (should be zero)
|
|
||||||
- * @event: fault event, when @type is %IOMMU_FAULT_DMA_UNRECOV
|
|
||||||
- * @prm: Page Request message, when @type is %IOMMU_FAULT_PAGE_REQ
|
|
||||||
- * @padding2: sets the fault size to allow for future extensions
|
|
||||||
- */
|
|
||||||
-struct iommu_fault {
|
|
||||||
- __u32 type;
|
|
||||||
- __u32 padding;
|
|
||||||
- union {
|
|
||||||
- struct iommu_fault_unrecoverable event;
|
|
||||||
- struct iommu_fault_page_request prm;
|
|
||||||
- __u8 padding2[56];
|
|
||||||
- };
|
|
||||||
-};
|
|
||||||
-
|
|
||||||
-/**
|
|
||||||
- * enum iommu_page_response_code - Return status of fault handlers
|
|
||||||
- * @IOMMU_PAGE_RESP_SUCCESS: Fault has been handled and the page tables
|
|
||||||
- * populated, retry the access. This is "Success" in PCI PRI.
|
|
||||||
- * @IOMMU_PAGE_RESP_FAILURE: General error. Drop all subsequent faults from
|
|
||||||
- * this device if possible. This is "Response Failure" in PCI PRI.
|
|
||||||
- * @IOMMU_PAGE_RESP_INVALID: Could not handle this fault, don't retry the
|
|
||||||
- * access. This is "Invalid Request" in PCI PRI.
|
|
||||||
- */
|
|
||||||
-enum iommu_page_response_code {
|
|
||||||
- IOMMU_PAGE_RESP_SUCCESS = 0,
|
|
||||||
- IOMMU_PAGE_RESP_INVALID,
|
|
||||||
- IOMMU_PAGE_RESP_FAILURE,
|
|
||||||
-};
|
|
||||||
-
|
|
||||||
-/**
|
|
||||||
- * struct iommu_page_response - Generic page response information
|
|
||||||
- * @argsz: User filled size of this data
|
|
||||||
- * @version: API version of this structure
|
|
||||||
- * @flags: encodes whether the corresponding fields are valid
|
|
||||||
- * (IOMMU_FAULT_PAGE_RESPONSE_* values)
|
|
||||||
- * @pasid: Process Address Space ID
|
|
||||||
- * @grpid: Page Request Group Index
|
|
||||||
- * @code: response code from &enum iommu_page_response_code
|
|
||||||
- */
|
|
||||||
-struct iommu_page_response {
|
|
||||||
- __u32 argsz;
|
|
||||||
-#define IOMMU_PAGE_RESP_VERSION_1 1
|
|
||||||
- __u32 version;
|
|
||||||
-#define IOMMU_PAGE_RESP_PASID_VALID (1 << 0)
|
|
||||||
- __u32 flags;
|
|
||||||
- __u32 pasid;
|
|
||||||
- __u32 grpid;
|
|
||||||
- __u32 code;
|
|
||||||
-};
|
|
||||||
-
|
|
||||||
-/* defines the granularity of the invalidation */
|
|
||||||
-enum iommu_inv_granularity {
|
|
||||||
- IOMMU_INV_GRANU_DOMAIN, /* domain-selective invalidation */
|
|
||||||
- IOMMU_INV_GRANU_PASID, /* PASID-selective invalidation */
|
|
||||||
- IOMMU_INV_GRANU_ADDR, /* page-selective invalidation */
|
|
||||||
- IOMMU_INV_GRANU_NR, /* number of invalidation granularities */
|
|
||||||
-};
|
|
||||||
-
|
|
||||||
-/**
|
|
||||||
- * struct iommu_inv_addr_info - Address Selective Invalidation Structure
|
|
||||||
- *
|
|
||||||
- * @flags: indicates the granularity of the address-selective invalidation
|
|
||||||
- * - If the PASID bit is set, the @pasid field is populated and the invalidation
|
|
||||||
- * relates to cache entries tagged with this PASID and matching the address
|
|
||||||
- * range.
|
|
||||||
- * - If ARCHID bit is set, @archid is populated and the invalidation relates
|
|
||||||
- * to cache entries tagged with this architecture specific ID and matching
|
|
||||||
- * the address range.
|
|
||||||
- * - Both PASID and ARCHID can be set as they may tag different caches.
|
|
||||||
- * - If neither PASID or ARCHID is set, global addr invalidation applies.
|
|
||||||
- * - The LEAF flag indicates whether only the leaf PTE caching needs to be
|
|
||||||
- * invalidated and other paging structure caches can be preserved.
|
|
||||||
- * @pasid: process address space ID
|
|
||||||
- * @archid: architecture-specific ID
|
|
||||||
- * @addr: first stage/level input address
|
|
||||||
- * @granule_size: page/block size of the mapping in bytes
|
|
||||||
- * @nb_granules: number of contiguous granules to be invalidated
|
|
||||||
- */
|
|
||||||
-struct iommu_inv_addr_info {
|
|
||||||
-#define IOMMU_INV_ADDR_FLAGS_PASID (1 << 0)
|
|
||||||
-#define IOMMU_INV_ADDR_FLAGS_ARCHID (1 << 1)
|
|
||||||
-#define IOMMU_INV_ADDR_FLAGS_LEAF (1 << 2)
|
|
||||||
- __u32 flags;
|
|
||||||
- __u32 archid;
|
|
||||||
- __u64 pasid;
|
|
||||||
- __u64 addr;
|
|
||||||
- __u64 granule_size;
|
|
||||||
- __u64 nb_granules;
|
|
||||||
-};
|
|
||||||
-
|
|
||||||
-/**
|
|
||||||
- * struct iommu_inv_pasid_info - PASID Selective Invalidation Structure
|
|
||||||
- *
|
|
||||||
- * @flags: indicates the granularity of the PASID-selective invalidation
|
|
||||||
- * - If the PASID bit is set, the @pasid field is populated and the invalidation
|
|
||||||
- * relates to cache entries tagged with this PASID and matching the address
|
|
||||||
- * range.
|
|
||||||
- * - If the ARCHID bit is set, the @archid is populated and the invalidation
|
|
||||||
- * relates to cache entries tagged with this architecture specific ID and
|
|
||||||
- * matching the address range.
|
|
||||||
- * - Both PASID and ARCHID can be set as they may tag different caches.
|
|
||||||
- * - At least one of PASID or ARCHID must be set.
|
|
||||||
- * @pasid: process address space ID
|
|
||||||
- * @archid: architecture-specific ID
|
|
||||||
- */
|
|
||||||
-struct iommu_inv_pasid_info {
|
|
||||||
-#define IOMMU_INV_PASID_FLAGS_PASID (1 << 0)
|
|
||||||
-#define IOMMU_INV_PASID_FLAGS_ARCHID (1 << 1)
|
|
||||||
- __u32 flags;
|
|
||||||
- __u32 archid;
|
|
||||||
- __u64 pasid;
|
|
||||||
-};
|
|
||||||
-
|
|
||||||
-/**
|
|
||||||
- * struct iommu_cache_invalidate_info - First level/stage invalidation
|
|
||||||
- * information
|
|
||||||
- * @argsz: User filled size of this data
|
|
||||||
- * @version: API version of this structure
|
|
||||||
- * @cache: bitfield that allows to select which caches to invalidate
|
|
||||||
- * @granularity: defines the lowest granularity used for the invalidation:
|
|
||||||
- * domain > PASID > addr
|
|
||||||
- * @padding: reserved for future use (should be zero)
|
|
||||||
- * @pasid_info: invalidation data when @granularity is %IOMMU_INV_GRANU_PASID
|
|
||||||
- * @addr_info: invalidation data when @granularity is %IOMMU_INV_GRANU_ADDR
|
|
||||||
- *
|
|
||||||
- * Not all the combinations of cache/granularity are valid:
|
|
||||||
- *
|
|
||||||
- * +--------------+---------------+---------------+---------------+
|
|
||||||
- * | type / | DEV_IOTLB | IOTLB | PASID |
|
|
||||||
- * | granularity | | | cache |
|
|
||||||
- * +==============+===============+===============+===============+
|
|
||||||
- * | DOMAIN | N/A | Y | Y |
|
|
||||||
- * +--------------+---------------+---------------+---------------+
|
|
||||||
- * | PASID | Y | Y | Y |
|
|
||||||
- * +--------------+---------------+---------------+---------------+
|
|
||||||
- * | ADDR | Y | Y | N/A |
|
|
||||||
- * +--------------+---------------+---------------+---------------+
|
|
||||||
- *
|
|
||||||
- * Invalidations by %IOMMU_INV_GRANU_DOMAIN don't take any argument other than
|
|
||||||
- * @version and @cache.
|
|
||||||
- *
|
|
||||||
- * If multiple cache types are invalidated simultaneously, they all
|
|
||||||
- * must support the used granularity.
|
|
||||||
- */
|
|
||||||
-struct iommu_cache_invalidate_info {
|
|
||||||
- __u32 argsz;
|
|
||||||
-#define IOMMU_CACHE_INVALIDATE_INFO_VERSION_1 1
|
|
||||||
- __u32 version;
|
|
||||||
-/* IOMMU paging structure cache */
|
|
||||||
-#define IOMMU_CACHE_INV_TYPE_IOTLB (1 << 0) /* IOMMU IOTLB */
|
|
||||||
-#define IOMMU_CACHE_INV_TYPE_DEV_IOTLB (1 << 1) /* Device IOTLB */
|
|
||||||
-#define IOMMU_CACHE_INV_TYPE_PASID (1 << 2) /* PASID cache */
|
|
||||||
-#define IOMMU_CACHE_INV_TYPE_NR (3)
|
|
||||||
- __u8 cache;
|
|
||||||
- __u8 granularity;
|
|
||||||
- __u8 padding[6];
|
|
||||||
- union {
|
|
||||||
- struct iommu_inv_pasid_info pasid_info;
|
|
||||||
- struct iommu_inv_addr_info addr_info;
|
|
||||||
- } granu;
|
|
||||||
-};
|
|
||||||
-
|
|
||||||
-/**
|
|
||||||
- * struct iommu_gpasid_bind_data_vtd - Intel VT-d specific data on device and guest
|
|
||||||
- * SVA binding.
|
|
||||||
- *
|
|
||||||
- * @flags: VT-d PASID table entry attributes
|
|
||||||
- * @pat: Page attribute table data to compute effective memory type
|
|
||||||
- * @emt: Extended memory type
|
|
||||||
- *
|
|
||||||
- * Only guest vIOMMU selectable and effective options are passed down to
|
|
||||||
- * the host IOMMU.
|
|
||||||
- */
|
|
||||||
-struct iommu_gpasid_bind_data_vtd {
|
|
||||||
-#define IOMMU_SVA_VTD_GPASID_SRE (1 << 0) /* supervisor request */
|
|
||||||
-#define IOMMU_SVA_VTD_GPASID_EAFE (1 << 1) /* extended access enable */
|
|
||||||
-#define IOMMU_SVA_VTD_GPASID_PCD (1 << 2) /* page-level cache disable */
|
|
||||||
-#define IOMMU_SVA_VTD_GPASID_PWT (1 << 3) /* page-level write through */
|
|
||||||
-#define IOMMU_SVA_VTD_GPASID_EMTE (1 << 4) /* extended mem type enable */
|
|
||||||
-#define IOMMU_SVA_VTD_GPASID_CD (1 << 5) /* PASID-level cache disable */
|
|
||||||
-#define IOMMU_SVA_VTD_GPASID_LAST (1 << 6)
|
|
||||||
- __u64 flags;
|
|
||||||
- __u32 pat;
|
|
||||||
- __u32 emt;
|
|
||||||
-};
|
|
||||||
-
|
|
||||||
-#define IOMMU_SVA_VTD_GPASID_MTS_MASK (IOMMU_SVA_VTD_GPASID_CD | \
|
|
||||||
- IOMMU_SVA_VTD_GPASID_EMTE | \
|
|
||||||
- IOMMU_SVA_VTD_GPASID_PCD | \
|
|
||||||
- IOMMU_SVA_VTD_GPASID_PWT)
|
|
||||||
-
|
|
||||||
-/**
|
|
||||||
- * struct iommu_gpasid_bind_data - Information about device and guest PASID binding
|
|
||||||
- * @argsz: User filled size of this data
|
|
||||||
- * @version: Version of this data structure
|
|
||||||
- * @format: PASID table entry format
|
|
||||||
- * @flags: Additional information on guest bind request
|
|
||||||
- * @gpgd: Guest page directory base of the guest mm to bind
|
|
||||||
- * @hpasid: Process address space ID used for the guest mm in host IOMMU
|
|
||||||
- * @gpasid: Process address space ID used for the guest mm in guest IOMMU
|
|
||||||
- * @addr_width: Guest virtual address width
|
|
||||||
- * @padding: Reserved for future use (should be zero)
|
|
||||||
- * @vtd: Intel VT-d specific data
|
|
||||||
- *
|
|
||||||
- * Guest to host PASID mapping can be an identity or non-identity, where guest
|
|
||||||
- * has its own PASID space. For non-identify mapping, guest to host PASID lookup
|
|
||||||
- * is needed when VM programs guest PASID into an assigned device. VMM may
|
|
||||||
- * trap such PASID programming then request host IOMMU driver to convert guest
|
|
||||||
- * PASID to host PASID based on this bind data.
|
|
||||||
- */
|
|
||||||
-struct iommu_gpasid_bind_data {
|
|
||||||
- __u32 argsz;
|
|
||||||
-#define IOMMU_GPASID_BIND_VERSION_1 1
|
|
||||||
- __u32 version;
|
|
||||||
-#define IOMMU_PASID_FORMAT_INTEL_VTD 1
|
|
||||||
-#define IOMMU_PASID_FORMAT_LAST 2
|
|
||||||
- __u32 format;
|
|
||||||
- __u32 addr_width;
|
|
||||||
-#define IOMMU_SVA_GPASID_VAL (1 << 0) /* guest PASID valid */
|
|
||||||
- __u64 flags;
|
|
||||||
- __u64 gpgd;
|
|
||||||
- __u64 hpasid;
|
|
||||||
- __u64 gpasid;
|
|
||||||
- __u8 padding[8];
|
|
||||||
- /* Vendor specific data */
|
|
||||||
- union {
|
|
||||||
- struct iommu_gpasid_bind_data_vtd vtd;
|
|
||||||
- } vendor;
|
|
||||||
-};
|
|
||||||
-
|
|
||||||
-/**
|
|
||||||
- * struct iommu_pasid_smmuv3 - ARM SMMUv3 Stream Table Entry stage 1 related
|
|
||||||
- * information
|
|
||||||
- * @version: API version of this structure
|
|
||||||
- * @s1fmt: STE s1fmt (format of the CD table: single CD, linear table
|
|
||||||
- * or 2-level table)
|
|
||||||
- * @s1dss: STE s1dss (specifies the behavior when @pasid_bits != 0
|
|
||||||
- * and no PASID is passed along with the incoming transaction)
|
|
||||||
- * @padding: reserved for future use (should be zero)
|
|
||||||
- *
|
|
||||||
- * The PASID table is referred to as the Context Descriptor (CD) table on ARM
|
|
||||||
- * SMMUv3. Please refer to the ARM SMMU 3.x spec (ARM IHI 0070A) for full
|
|
||||||
- * details.
|
|
||||||
- */
|
|
||||||
-struct iommu_pasid_smmuv3 {
|
|
||||||
-#define PASID_TABLE_SMMUV3_CFG_VERSION_1 1
|
|
||||||
- __u32 version;
|
|
||||||
- __u8 s1fmt;
|
|
||||||
- __u8 s1dss;
|
|
||||||
- __u8 padding[2];
|
|
||||||
-};
|
|
||||||
-
|
|
||||||
-/**
|
|
||||||
- * struct iommu_pasid_table_config - PASID table data used to bind guest PASID
|
|
||||||
- * table to the host IOMMU
|
|
||||||
- * @argsz: User filled size of this data
|
|
||||||
- * @version: API version to prepare for future extensions
|
|
||||||
- * @base_ptr: guest physical address of the PASID table
|
|
||||||
- * @format: format of the PASID table
|
|
||||||
- * @pasid_bits: number of PASID bits used in the PASID table
|
|
||||||
- * @config: indicates whether the guest translation stage must
|
|
||||||
- * be translated, bypassed or aborted.
|
|
||||||
- * @padding: reserved for future use (should be zero)
|
|
||||||
- * @vendor_data.smmuv3: table information when @format is
|
|
||||||
- * %IOMMU_PASID_FORMAT_SMMUV3
|
|
||||||
- */
|
|
||||||
-struct iommu_pasid_table_config {
|
|
||||||
- __u32 argsz;
|
|
||||||
-#define PASID_TABLE_CFG_VERSION_1 1
|
|
||||||
- __u32 version;
|
|
||||||
- __u64 base_ptr;
|
|
||||||
-#define IOMMU_PASID_FORMAT_SMMUV3 1
|
|
||||||
- __u32 format;
|
|
||||||
- __u8 pasid_bits;
|
|
||||||
-#define IOMMU_PASID_CONFIG_TRANSLATE 1
|
|
||||||
-#define IOMMU_PASID_CONFIG_BYPASS 2
|
|
||||||
-#define IOMMU_PASID_CONFIG_ABORT 3
|
|
||||||
- __u8 config;
|
|
||||||
- __u8 padding[2];
|
|
||||||
- union {
|
|
||||||
- struct iommu_pasid_smmuv3 smmuv3;
|
|
||||||
- } vendor_data;
|
|
||||||
-};
|
|
||||||
-
|
|
||||||
-#endif /* _UAPI_IOMMU_H */
|
|
||||||
diff --git a/linux-headers/linux/vfio.h b/linux-headers/linux/vfio.h
|
|
||||||
index cf8e208fac..f4ff038e8c 100644
|
|
||||||
--- a/linux-headers/linux/vfio.h
|
|
||||||
+++ b/linux-headers/linux/vfio.h
|
|
||||||
@@ -14,7 +14,6 @@
|
|
||||||
|
|
||||||
#include <linux/types.h>
|
|
||||||
#include <linux/ioctl.h>
|
|
||||||
-#include <linux/iommu.h>
|
|
||||||
|
|
||||||
#define VFIO_API_VERSION 0
|
|
||||||
|
|
||||||
@@ -335,7 +334,6 @@ struct vfio_region_info_cap_type {
|
|
||||||
#define VFIO_REGION_TYPE_GFX (1)
|
|
||||||
#define VFIO_REGION_TYPE_CCW (2)
|
|
||||||
#define VFIO_REGION_TYPE_MIGRATION (3)
|
|
||||||
-#define VFIO_REGION_TYPE_NESTED (4)
|
|
||||||
|
|
||||||
/* sub-types for VFIO_REGION_TYPE_PCI_* */
|
|
||||||
|
|
||||||
@@ -364,10 +362,6 @@ struct vfio_region_info_cap_type {
|
|
||||||
/* sub-types for VFIO_REGION_TYPE_GFX */
|
|
||||||
#define VFIO_REGION_SUBTYPE_GFX_EDID (1)
|
|
||||||
|
|
||||||
-/* sub-types for VFIO_REGION_TYPE_NESTED */
|
|
||||||
-#define VFIO_REGION_SUBTYPE_NESTED_DMA_FAULT (1)
|
|
||||||
-#define VFIO_REGION_SUBTYPE_NESTED_DMA_FAULT_RESPONSE (2)
|
|
||||||
-
|
|
||||||
/**
|
|
||||||
* struct vfio_region_gfx_edid - EDID region layout.
|
|
||||||
*
|
|
||||||
@@ -727,30 +721,11 @@ struct vfio_irq_info {
|
|
||||||
#define VFIO_IRQ_INFO_MASKABLE (1 << 1)
|
|
||||||
#define VFIO_IRQ_INFO_AUTOMASKED (1 << 2)
|
|
||||||
#define VFIO_IRQ_INFO_NORESIZE (1 << 3)
|
|
||||||
-#define VFIO_IRQ_INFO_FLAG_CAPS (1 << 4) /* Info supports caps */
|
|
||||||
__u32 index; /* IRQ index */
|
|
||||||
__u32 count; /* Number of IRQs within this index */
|
|
||||||
- __u32 cap_offset; /* Offset within info struct of first cap */
|
|
||||||
};
|
|
||||||
#define VFIO_DEVICE_GET_IRQ_INFO _IO(VFIO_TYPE, VFIO_BASE + 9)
|
|
||||||
|
|
||||||
-/*
|
|
||||||
- * The irq type capability allows IRQs unique to a specific device or
|
|
||||||
- * class of devices to be exposed.
|
|
||||||
- *
|
|
||||||
- * The structures below define version 1 of this capability.
|
|
||||||
- */
|
|
||||||
-#define VFIO_IRQ_INFO_CAP_TYPE 3
|
|
||||||
-
|
|
||||||
-struct vfio_irq_info_cap_type {
|
|
||||||
- struct vfio_info_cap_header header;
|
|
||||||
- __u32 type; /* global per bus driver */
|
|
||||||
- __u32 subtype; /* type specific */
|
|
||||||
-};
|
|
||||||
-
|
|
||||||
-#define VFIO_IRQ_TYPE_NESTED (1)
|
|
||||||
-#define VFIO_IRQ_SUBTYPE_DMA_FAULT (1)
|
|
||||||
-
|
|
||||||
/**
|
|
||||||
* VFIO_DEVICE_SET_IRQS - _IOW(VFIO_TYPE, VFIO_BASE + 10, struct vfio_irq_set)
|
|
||||||
*
|
|
||||||
@@ -852,8 +827,7 @@ enum {
|
|
||||||
VFIO_PCI_MSIX_IRQ_INDEX,
|
|
||||||
VFIO_PCI_ERR_IRQ_INDEX,
|
|
||||||
VFIO_PCI_REQ_IRQ_INDEX,
|
|
||||||
- VFIO_PCI_NUM_IRQS = 5 /* Fixed user ABI, IRQ indexes >=5 use */
|
|
||||||
- /* device specific cap to define content */
|
|
||||||
+ VFIO_PCI_NUM_IRQS
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
@@ -1038,68 +1012,6 @@ struct vfio_device_feature {
|
|
||||||
*/
|
|
||||||
#define VFIO_DEVICE_FEATURE_PCI_VF_TOKEN (0)
|
|
||||||
|
|
||||||
-/*
|
|
||||||
- * Capability exposed by the DMA fault region
|
|
||||||
- * @version: ABI version
|
|
||||||
- */
|
|
||||||
-#define VFIO_REGION_INFO_CAP_DMA_FAULT 6
|
|
||||||
-
|
|
||||||
-struct vfio_region_info_cap_fault {
|
|
||||||
- struct vfio_info_cap_header header;
|
|
||||||
- __u32 version;
|
|
||||||
-};
|
|
||||||
-
|
|
||||||
-/*
|
|
||||||
- * Capability exposed by the DMA fault response region
|
|
||||||
- * @version: ABI version
|
|
||||||
- */
|
|
||||||
-#define VFIO_REGION_INFO_CAP_DMA_FAULT_RESPONSE 7
|
|
||||||
-
|
|
||||||
-struct vfio_region_info_cap_fault_response {
|
|
||||||
- struct vfio_info_cap_header header;
|
|
||||||
- __u32 version;
|
|
||||||
-};
|
|
||||||
-
|
|
||||||
-/*
|
|
||||||
- * DMA Fault Region Layout
|
|
||||||
- * @tail: index relative to the start of the ring buffer at which the
|
|
||||||
- * consumer finds the next item in the buffer
|
|
||||||
- * @entry_size: fault ring buffer entry size in bytes
|
|
||||||
- * @nb_entries: max capacity of the fault ring buffer
|
|
||||||
- * @offset: ring buffer offset relative to the start of the region
|
|
||||||
- * @head: index relative to the start of the ring buffer at which the
|
|
||||||
- * producer (kernel) inserts items into the buffers
|
|
||||||
- */
|
|
||||||
-struct vfio_region_dma_fault {
|
|
||||||
- /* Write-Only */
|
|
||||||
- __u32 tail;
|
|
||||||
- /* Read-Only */
|
|
||||||
- __u32 entry_size;
|
|
||||||
- __u32 nb_entries;
|
|
||||||
- __u32 offset;
|
|
||||||
- __u32 head;
|
|
||||||
-};
|
|
||||||
-
|
|
||||||
-/*
|
|
||||||
- * DMA Fault Response Region Layout
|
|
||||||
- * @head: index relative to the start of the ring buffer at which the
|
|
||||||
- * producer (userspace) insert responses into the buffer
|
|
||||||
- * @entry_size: fault ring buffer entry size in bytes
|
|
||||||
- * @nb_entries: max capacity of the fault ring buffer
|
|
||||||
- * @offset: ring buffer offset relative to the start of the region
|
|
||||||
- * @tail: index relative to the start of the ring buffer at which the
|
|
||||||
- * consumer (kernel) finds the next item in the buffer
|
|
||||||
- */
|
|
||||||
-struct vfio_region_dma_fault_response {
|
|
||||||
- /* Write-Only */
|
|
||||||
- __u32 head;
|
|
||||||
- /* Read-Only */
|
|
||||||
- __u32 entry_size;
|
|
||||||
- __u32 nb_entries;
|
|
||||||
- __u32 offset;
|
|
||||||
- __u32 tail;
|
|
||||||
-};
|
|
||||||
-
|
|
||||||
/* -------- API for Type1 VFIO IOMMU -------- */
|
|
||||||
|
|
||||||
/**
|
|
||||||
@@ -1212,7 +1124,7 @@ struct vfio_iommu_type1_dma_map {
|
|
||||||
struct vfio_bitmap {
|
|
||||||
__u64 pgsize; /* page size for bitmap in bytes */
|
|
||||||
__u64 size; /* in bytes */
|
|
||||||
- __u64 *data; /* one bit per page */
|
|
||||||
+ __u64 *data; /* one bit per page */
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
@@ -1338,134 +1250,6 @@ struct vfio_iommu_type1_dirty_bitmap_get {
|
|
||||||
|
|
||||||
#define VFIO_IOMMU_DIRTY_PAGES _IO(VFIO_TYPE, VFIO_BASE + 17)
|
|
||||||
|
|
||||||
-/*
|
|
||||||
- * VFIO_IOMMU_BIND_PROCESS
|
|
||||||
- *
|
|
||||||
- * Allocate a PASID for a process address space, and use it to attach this
|
|
||||||
- * process to all devices in the container. Devices can then tag their DMA
|
|
||||||
- * traffic with the returned @pasid to perform transactions on the associated
|
|
||||||
- * virtual address space. Mapping and unmapping buffers is performed by standard
|
|
||||||
- * functions such as mmap and malloc.
|
|
||||||
- *
|
|
||||||
- * If flag is VFIO_IOMMU_BIND_PID, @pid contains the pid of a foreign process to
|
|
||||||
- * bind. Otherwise the current task is bound. Given that the caller owns the
|
|
||||||
- * device, setting this flag grants the caller read and write permissions on the
|
|
||||||
- * entire address space of foreign process described by @pid. Therefore,
|
|
||||||
- * permission to perform the bind operation on a foreign process is governed by
|
|
||||||
- * the ptrace access mode PTRACE_MODE_ATTACH_REALCREDS check. See man ptrace(2)
|
|
||||||
- * for more information.
|
|
||||||
- *
|
|
||||||
- * On success, VFIO writes a Process Address Space ID (PASID) into @pasid. This
|
|
||||||
- * ID is unique to a process and can be used on all devices in the container.
|
|
||||||
- *
|
|
||||||
- * On fork, the child inherits the device fd and can use the bonds setup by its
|
|
||||||
- * parent. Consequently, the child has R/W access on the address spaces bound by
|
|
||||||
- * its parent. After an execv, the device fd is closed and the child doesn't
|
|
||||||
- * have access to the address space anymore.
|
|
||||||
- *
|
|
||||||
- * To remove a bond between process and container, VFIO_IOMMU_UNBIND ioctl is
|
|
||||||
- * issued with the same parameters. If a pid was specified in VFIO_IOMMU_BIND,
|
|
||||||
- * it should also be present for VFIO_IOMMU_UNBIND. Otherwise unbind the current
|
|
||||||
- * task from the container.
|
|
||||||
- */
|
|
||||||
-struct vfio_iommu_type1_bind_process {
|
|
||||||
- __u32 flags;
|
|
||||||
-#define VFIO_IOMMU_BIND_PID (1 << 0)
|
|
||||||
- __u32 pasid;
|
|
||||||
- __s32 pid;
|
|
||||||
-};
|
|
||||||
-
|
|
||||||
-/*
|
|
||||||
- * Only mode supported at the moment is VFIO_IOMMU_BIND_PROCESS, which takes
|
|
||||||
- * vfio_iommu_type1_bind_process in data.
|
|
||||||
- */
|
|
||||||
-struct vfio_iommu_type1_bind {
|
|
||||||
- __u32 argsz;
|
|
||||||
- __u32 flags;
|
|
||||||
-#define VFIO_IOMMU_BIND_PROCESS (1 << 0)
|
|
||||||
- __u8 data[];
|
|
||||||
-};
|
|
||||||
-
|
|
||||||
-/*
|
|
||||||
- * VFIO_IOMMU_BIND - _IOWR(VFIO_TYPE, VFIO_BASE + 22, struct vfio_iommu_bind)
|
|
||||||
- *
|
|
||||||
- * Manage address spaces of devices in this container. Initially a TYPE1
|
|
||||||
- * container can only have one address space, managed with
|
|
||||||
- * VFIO_IOMMU_MAP/UNMAP_DMA.
|
|
||||||
- *
|
|
||||||
- * An IOMMU of type VFIO_TYPE1_NESTING_IOMMU can be managed by both MAP/UNMAP
|
|
||||||
- * and BIND ioctls at the same time. MAP/UNMAP acts on the stage-2 (host) page
|
|
||||||
- * tables, and BIND manages the stage-1 (guest) page tables. Other types of
|
|
||||||
- * IOMMU may allow MAP/UNMAP and BIND to coexist, where MAP/UNMAP controls
|
|
||||||
- * non-PASID traffic and BIND controls PASID traffic. But this depends on the
|
|
||||||
- * underlying IOMMU architecture and isn't guaranteed.
|
|
||||||
- *
|
|
||||||
- * Availability of this feature depends on the device, its bus, the underlying
|
|
||||||
- * IOMMU and the CPU architecture.
|
|
||||||
- *
|
|
||||||
- * returns: 0 on success, -errno on failure.
|
|
||||||
- */
|
|
||||||
-#define VFIO_IOMMU_BIND _IO(VFIO_TYPE, VFIO_BASE + 22)
|
|
||||||
-
|
|
||||||
-/*
|
|
||||||
- * VFIO_IOMMU_UNBIND - _IOWR(VFIO_TYPE, VFIO_BASE + 23, struct vfio_iommu_bind)
|
|
||||||
- *
|
|
||||||
- * Undo what was done by the corresponding VFIO_IOMMU_BIND ioctl.
|
|
||||||
- */
|
|
||||||
-#define VFIO_IOMMU_UNBIND _IO(VFIO_TYPE, VFIO_BASE + 23)
|
|
||||||
-
|
|
||||||
-/*
|
|
||||||
- * VFIO_IOMMU_SET_PASID_TABLE - _IOWR(VFIO_TYPE, VFIO_BASE + 18,
|
|
||||||
- * struct vfio_iommu_type1_set_pasid_table)
|
|
||||||
- *
|
|
||||||
- * The SET operation passes a PASID table to the host while the
|
|
||||||
- * UNSET operation detaches the one currently programmed. It is
|
|
||||||
- * allowed to "SET" the table several times without unsetting as
|
|
||||||
- * long as the table config does not stay IOMMU_PASID_CONFIG_TRANSLATE.
|
|
||||||
- */
|
|
||||||
-struct vfio_iommu_type1_set_pasid_table {
|
|
||||||
- __u32 argsz;
|
|
||||||
- __u32 flags;
|
|
||||||
-#define VFIO_PASID_TABLE_FLAG_SET (1 << 0)
|
|
||||||
-#define VFIO_PASID_TABLE_FLAG_UNSET (1 << 1)
|
|
||||||
- struct iommu_pasid_table_config config; /* used on SET */
|
|
||||||
-};
|
|
||||||
-
|
|
||||||
-#define VFIO_IOMMU_SET_PASID_TABLE _IO(VFIO_TYPE, VFIO_BASE + 18)
|
|
||||||
-
|
|
||||||
-/**
|
|
||||||
- * VFIO_IOMMU_CACHE_INVALIDATE - _IOWR(VFIO_TYPE, VFIO_BASE + 19,
|
|
||||||
- * struct vfio_iommu_type1_cache_invalidate)
|
|
||||||
- *
|
|
||||||
- * Propagate guest IOMMU cache invalidation to the host.
|
|
||||||
- */
|
|
||||||
-struct vfio_iommu_type1_cache_invalidate {
|
|
||||||
- __u32 argsz;
|
|
||||||
- __u32 flags;
|
|
||||||
- struct iommu_cache_invalidate_info info;
|
|
||||||
-};
|
|
||||||
-#define VFIO_IOMMU_CACHE_INVALIDATE _IO(VFIO_TYPE, VFIO_BASE + 19)
|
|
||||||
-
|
|
||||||
-/**
|
|
||||||
- * VFIO_IOMMU_SET_MSI_BINDING - _IOWR(VFIO_TYPE, VFIO_BASE + 20,
|
|
||||||
- * struct vfio_iommu_type1_set_msi_binding)
|
|
||||||
- *
|
|
||||||
- * Pass a stage 1 MSI doorbell mapping to the host so that this
|
|
||||||
- * latter can build a nested stage2 mapping. Or conversely tear
|
|
||||||
- * down a previously bound stage 1 MSI binding.
|
|
||||||
- */
|
|
||||||
-struct vfio_iommu_type1_set_msi_binding {
|
|
||||||
- __u32 argsz;
|
|
||||||
- __u32 flags;
|
|
||||||
-#define VFIO_IOMMU_BIND_MSI (1 << 0)
|
|
||||||
-#define VFIO_IOMMU_UNBIND_MSI (1 << 1)
|
|
||||||
- __u64 iova; /* MSI guest IOVA */
|
|
||||||
- /* Fields below are used on BIND */
|
|
||||||
- __u64 gpa; /* MSI guest physical address */
|
|
||||||
- __u64 size; /* size of stage1 mapping (bytes) */
|
|
||||||
-};
|
|
||||||
-#define VFIO_IOMMU_SET_MSI_BINDING _IO(VFIO_TYPE, VFIO_BASE + 20)
|
|
||||||
-
|
|
||||||
/* -------- Additional API for SPAPR TCE (Server POWERPC) IOMMU -------- */
|
|
||||||
|
|
||||||
/*
|
|
||||||
--
|
|
||||||
2.27.0
|
|
||||||
|
|
||||||
@ -1,163 +0,0 @@
|
|||||||
From 529074fd45a543a9259441e02652c3ac60673d07 Mon Sep 17 00:00:00 2001
|
|
||||||
From: fangyi <eric.fangyi@huawei.com>
|
|
||||||
Date: Wed, 22 Nov 2023 09:53:34 +0800
|
|
||||||
Subject: [PATCH] Revert "vhost: add support for configure interrupt"
|
|
||||||
|
|
||||||
This reverts commit f7220a7ce21604a4bc6260ccca4dc9068c1f27f2.
|
|
||||||
|
|
||||||
Fixes: f7220a7ce2 ("vhost: add support for configure interrupt")
|
|
||||||
Cc: "Cindy Lu" <lulu@redhat.com>
|
|
||||||
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
|
|
||||||
Signed-off-by: fangyi <eric.fangyi@huawei.com>
|
|
||||||
---
|
|
||||||
hw/virtio/vhost.c | 76 ---------------------------------------
|
|
||||||
include/hw/virtio/vhost.h | 4 ---
|
|
||||||
2 files changed, 80 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
|
|
||||||
index caa53443ab..2f9bb96d63 100644
|
|
||||||
--- a/hw/virtio/vhost.c
|
|
||||||
+++ b/hw/virtio/vhost.c
|
|
||||||
@@ -1581,67 +1581,6 @@ void vhost_virtqueue_mask(struct vhost_dev *hdev, VirtIODevice *vdev, int n,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
-bool vhost_config_pending(struct vhost_dev *hdev)
|
|
||||||
-{
|
|
||||||
- assert(hdev->vhost_ops);
|
|
||||||
- if ((hdev->started == false) ||
|
|
||||||
- (hdev->vhost_ops->vhost_set_config_call == NULL)) {
|
|
||||||
- return false;
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
- EventNotifier *notifier =
|
|
||||||
- &hdev->vqs[VHOST_QUEUE_NUM_CONFIG_INR].masked_config_notifier;
|
|
||||||
- return event_notifier_test_and_clear(notifier);
|
|
||||||
-}
|
|
||||||
-
|
|
||||||
-void vhost_config_mask(struct vhost_dev *hdev, VirtIODevice *vdev, bool mask)
|
|
||||||
-{
|
|
||||||
- int fd;
|
|
||||||
- int r;
|
|
||||||
- EventNotifier *notifier =
|
|
||||||
- &hdev->vqs[VHOST_QUEUE_NUM_CONFIG_INR].masked_config_notifier;
|
|
||||||
- EventNotifier *config_notifier = &vdev->config_notifier;
|
|
||||||
- assert(hdev->vhost_ops);
|
|
||||||
-
|
|
||||||
- if ((hdev->started == false) ||
|
|
||||||
- (hdev->vhost_ops->vhost_set_config_call == NULL)) {
|
|
||||||
- return;
|
|
||||||
- }
|
|
||||||
- if (mask) {
|
|
||||||
- assert(vdev->use_guest_notifier_mask);
|
|
||||||
- fd = event_notifier_get_fd(notifier);
|
|
||||||
- } else {
|
|
||||||
- fd = event_notifier_get_fd(config_notifier);
|
|
||||||
- }
|
|
||||||
- r = hdev->vhost_ops->vhost_set_config_call(hdev, fd);
|
|
||||||
- if (r < 0) {
|
|
||||||
- VHOST_OPS_DEBUG(r, "vhost_set_config_call failed");
|
|
||||||
- }
|
|
||||||
-}
|
|
||||||
-
|
|
||||||
-static void vhost_stop_config_intr(struct vhost_dev *dev)
|
|
||||||
-{
|
|
||||||
- int fd = -1;
|
|
||||||
- assert(dev->vhost_ops);
|
|
||||||
- if (dev->vhost_ops->vhost_set_config_call) {
|
|
||||||
- dev->vhost_ops->vhost_set_config_call(dev, fd);
|
|
||||||
- }
|
|
||||||
-}
|
|
||||||
-
|
|
||||||
-static void vhost_start_config_intr(struct vhost_dev *dev)
|
|
||||||
-{
|
|
||||||
- int r;
|
|
||||||
-
|
|
||||||
- assert(dev->vhost_ops);
|
|
||||||
- int fd = event_notifier_get_fd(&dev->vdev->config_notifier);
|
|
||||||
- if (dev->vhost_ops->vhost_set_config_call) {
|
|
||||||
- r = dev->vhost_ops->vhost_set_config_call(dev, fd);
|
|
||||||
- if (!r) {
|
|
||||||
- event_notifier_set(&dev->vdev->config_notifier);
|
|
||||||
- }
|
|
||||||
- }
|
|
||||||
-}
|
|
||||||
-
|
|
||||||
uint64_t vhost_get_features(struct vhost_dev *hdev, const int *feature_bits,
|
|
||||||
uint64_t features)
|
|
||||||
{
|
|
||||||
@@ -1854,16 +1793,6 @@ int vhost_dev_start(struct vhost_dev *hdev, VirtIODevice *vdev)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
- r = event_notifier_init(
|
|
||||||
- &hdev->vqs[VHOST_QUEUE_NUM_CONFIG_INR].masked_config_notifier, 0);
|
|
||||||
- if (r < 0) {
|
|
||||||
- return r;
|
|
||||||
- }
|
|
||||||
- event_notifier_test_and_clear(
|
|
||||||
- &hdev->vqs[VHOST_QUEUE_NUM_CONFIG_INR].masked_config_notifier);
|
|
||||||
- if (!vdev->use_guest_notifier_mask) {
|
|
||||||
- vhost_config_mask(hdev, vdev, true);
|
|
||||||
- }
|
|
||||||
if (hdev->log_enabled) {
|
|
||||||
uint64_t log_base;
|
|
||||||
|
|
||||||
@@ -1896,7 +1825,6 @@ int vhost_dev_start(struct vhost_dev *hdev, VirtIODevice *vdev)
|
|
||||||
vhost_device_iotlb_miss(hdev, vq->used_phys, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
- vhost_start_config_intr(hdev);
|
|
||||||
return 0;
|
|
||||||
fail_log:
|
|
||||||
vhost_log_put(hdev, false);
|
|
||||||
@@ -1922,9 +1850,6 @@ void vhost_dev_stop(struct vhost_dev *hdev, VirtIODevice *vdev)
|
|
||||||
|
|
||||||
/* should only be called after backend is connected */
|
|
||||||
assert(hdev->vhost_ops);
|
|
||||||
- event_notifier_test_and_clear(
|
|
||||||
- &hdev->vqs[VHOST_QUEUE_NUM_CONFIG_INR].masked_config_notifier);
|
|
||||||
- event_notifier_test_and_clear(&vdev->config_notifier);
|
|
||||||
|
|
||||||
if (hdev->vhost_ops->vhost_dev_start) {
|
|
||||||
hdev->vhost_ops->vhost_dev_start(hdev, false);
|
|
||||||
@@ -1942,7 +1867,6 @@ void vhost_dev_stop(struct vhost_dev *hdev, VirtIODevice *vdev)
|
|
||||||
}
|
|
||||||
memory_listener_unregister(&hdev->iommu_listener);
|
|
||||||
}
|
|
||||||
- vhost_stop_config_intr(hdev);
|
|
||||||
vhost_log_put(hdev, true);
|
|
||||||
hdev->started = false;
|
|
||||||
hdev->vdev = NULL;
|
|
||||||
diff --git a/include/hw/virtio/vhost.h b/include/hw/virtio/vhost.h
|
|
||||||
index 2ae5c3bfd8..86f36f0106 100644
|
|
||||||
--- a/include/hw/virtio/vhost.h
|
|
||||||
+++ b/include/hw/virtio/vhost.h
|
|
||||||
@@ -29,7 +29,6 @@ struct vhost_virtqueue {
|
|
||||||
unsigned long long used_phys;
|
|
||||||
unsigned used_size;
|
|
||||||
EventNotifier masked_notifier;
|
|
||||||
- EventNotifier masked_config_notifier;
|
|
||||||
struct vhost_dev *dev;
|
|
||||||
};
|
|
||||||
|
|
||||||
@@ -38,7 +37,6 @@ typedef unsigned long vhost_log_chunk_t;
|
|
||||||
#define VHOST_LOG_BITS (8 * sizeof(vhost_log_chunk_t))
|
|
||||||
#define VHOST_LOG_CHUNK (VHOST_LOG_PAGE * VHOST_LOG_BITS)
|
|
||||||
#define VHOST_INVALID_FEATURE_BIT (0xff)
|
|
||||||
-#define VHOST_QUEUE_NUM_CONFIG_INR 0
|
|
||||||
|
|
||||||
struct vhost_log {
|
|
||||||
unsigned long long size;
|
|
||||||
@@ -118,8 +116,6 @@ int vhost_dev_start(struct vhost_dev *hdev, VirtIODevice *vdev);
|
|
||||||
void vhost_dev_stop(struct vhost_dev *hdev, VirtIODevice *vdev);
|
|
||||||
int vhost_dev_enable_notifiers(struct vhost_dev *hdev, VirtIODevice *vdev);
|
|
||||||
void vhost_dev_disable_notifiers(struct vhost_dev *hdev, VirtIODevice *vdev);
|
|
||||||
-bool vhost_config_pending(struct vhost_dev *hdev);
|
|
||||||
-void vhost_config_mask(struct vhost_dev *hdev, VirtIODevice *vdev, bool mask);
|
|
||||||
|
|
||||||
/* Test and clear masked event pending status.
|
|
||||||
* Should be called after unmask to avoid losing events.
|
|
||||||
--
|
|
||||||
2.27.0
|
|
||||||
|
|
||||||
@ -1,36 +0,0 @@
|
|||||||
From 0ad1ce1ff54a4d654c00e4a3b95361b519f4fd37 Mon Sep 17 00:00:00 2001
|
|
||||||
From: fangyi <eric.fangyi@huawei.com>
|
|
||||||
Date: Wed, 22 Nov 2023 09:43:37 +0800
|
|
||||||
Subject: [PATCH] Revert "vhost: introduce new VhostOps vhost_set_config_call"
|
|
||||||
|
|
||||||
This reverts commit af8377d0e9437401ad30d80a27ab1fcf8252fad1.
|
|
||||||
|
|
||||||
Signed-off-by: fangyi <eric.fangyi@huawei.com>
|
|
||||||
---
|
|
||||||
include/hw/virtio/vhost-backend.h | 3 ---
|
|
||||||
1 file changed, 3 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/include/hw/virtio/vhost-backend.h b/include/hw/virtio/vhost-backend.h
|
|
||||||
index bd1c7dfe4f..a64708f456 100644
|
|
||||||
--- a/include/hw/virtio/vhost-backend.h
|
|
||||||
+++ b/include/hw/virtio/vhost-backend.h
|
|
||||||
@@ -125,8 +125,6 @@ typedef int (*vhost_vq_get_addr_op)(struct vhost_dev *dev,
|
|
||||||
typedef int (*vhost_get_device_id_op)(struct vhost_dev *dev, uint32_t *dev_id);
|
|
||||||
|
|
||||||
typedef bool (*vhost_force_iommu_op)(struct vhost_dev *dev);
|
|
||||||
-typedef int (*vhost_set_config_call_op)(struct vhost_dev *dev,
|
|
||||||
- int fd);
|
|
||||||
typedef void (*vhost_set_used_memslots_op)(struct vhost_dev *dev);
|
|
||||||
typedef unsigned int (*vhost_get_used_memslots_op)(void);
|
|
||||||
|
|
||||||
@@ -175,7 +173,6 @@ typedef struct VhostOps {
|
|
||||||
vhost_vq_get_addr_op vhost_vq_get_addr;
|
|
||||||
vhost_get_device_id_op vhost_get_device_id;
|
|
||||||
vhost_force_iommu_op vhost_force_iommu;
|
|
||||||
- vhost_set_config_call_op vhost_set_config_call;
|
|
||||||
vhost_set_used_memslots_op vhost_set_used_memslots;
|
|
||||||
vhost_get_used_memslots_op vhost_get_used_memslots;
|
|
||||||
} VhostOps;
|
|
||||||
--
|
|
||||||
2.27.0
|
|
||||||
|
|
||||||
@ -1,56 +0,0 @@
|
|||||||
From 92df45517567838512512f093f418067c857e8dc Mon Sep 17 00:00:00 2001
|
|
||||||
From: fangyi <eric.fangyi@huawei.com>
|
|
||||||
Date: Wed, 22 Nov 2023 09:58:20 +0800
|
|
||||||
Subject: [PATCH] Revert "vhost-vdpa: add support for config interrupt"
|
|
||||||
|
|
||||||
This reverts commit 634f7c89fbd78f57d00d5d6b39c0ade9df1fe27f.
|
|
||||||
|
|
||||||
Fixes: 634f7c89fb ("vhost-vdpa: add support for config interrupt")
|
|
||||||
Cc: "Cindy Lu" <lulu@redhat.com>
|
|
||||||
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
|
|
||||||
Signed-off-by: fangyi <eric.fangyi@huawei.com>
|
|
||||||
---
|
|
||||||
hw/virtio/trace-events | 1 -
|
|
||||||
hw/virtio/vhost-vdpa.c | 7 -------
|
|
||||||
2 files changed, 8 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/hw/virtio/trace-events b/hw/virtio/trace-events
|
|
||||||
index 39c36ff7a6..650e521e35 100644
|
|
||||||
--- a/hw/virtio/trace-events
|
|
||||||
+++ b/hw/virtio/trace-events
|
|
||||||
@@ -53,7 +53,6 @@ vhost_vdpa_get_features(void *dev, uint64_t features) "dev: %p features: 0x%"PRI
|
|
||||||
vhost_vdpa_set_owner(void *dev) "dev: %p"
|
|
||||||
vhost_vdpa_vq_get_addr(void *dev, void *vq, uint64_t desc_user_addr, uint64_t avail_user_addr, uint64_t used_user_addr) "dev: %p vq: %p desc_user_addr: 0x%"PRIx64" avail_user_addr: 0x%"PRIx64" used_user_addr: 0x%"PRIx64
|
|
||||||
vhost_vdpa_get_iova_range(void *dev, uint64_t first, uint64_t last) "dev: %p first: 0x%"PRIx64" last: 0x%"PRIx64
|
|
||||||
-vhost_vdpa_set_config_call(void *dev, int fd)"dev: %p fd: %d"
|
|
||||||
|
|
||||||
# virtio.c
|
|
||||||
virtqueue_alloc_element(void *elem, size_t sz, unsigned in_num, unsigned out_num) "elem %p size %zd in_num %u out_num %u"
|
|
||||||
diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c
|
|
||||||
index d8fba0b714..25a2f570a2 100644
|
|
||||||
--- a/hw/virtio/vhost-vdpa.c
|
|
||||||
+++ b/hw/virtio/vhost-vdpa.c
|
|
||||||
@@ -737,12 +737,6 @@ static int vhost_vdpa_set_vring_call(struct vhost_dev *dev,
|
|
||||||
trace_vhost_vdpa_set_vring_call(dev, file->index, file->fd);
|
|
||||||
return vhost_vdpa_call(dev, VHOST_SET_VRING_CALL, file);
|
|
||||||
}
|
|
||||||
-static int vhost_vdpa_set_config_call(struct vhost_dev *dev,
|
|
||||||
- int fd)
|
|
||||||
-{
|
|
||||||
- trace_vhost_vdpa_set_config_call(dev, fd);
|
|
||||||
- return vhost_vdpa_call(dev, VHOST_VDPA_SET_CONFIG_CALL, &fd);
|
|
||||||
-}
|
|
||||||
|
|
||||||
static int vhost_vdpa_get_features(struct vhost_dev *dev,
|
|
||||||
uint64_t *features)
|
|
||||||
@@ -823,7 +817,6 @@ const VhostOps vdpa_ops = {
|
|
||||||
.vhost_get_device_id = vhost_vdpa_get_device_id,
|
|
||||||
.vhost_vq_get_addr = vhost_vdpa_vq_get_addr,
|
|
||||||
.vhost_force_iommu = vhost_vdpa_force_iommu,
|
|
||||||
- .vhost_set_config_call = vhost_vdpa_set_config_call,
|
|
||||||
.vhost_set_used_memslots = vhost_vdpa_set_used_memslots,
|
|
||||||
.vhost_get_used_memslots = vhost_vdpa_get_used_memslots,
|
|
||||||
};
|
|
||||||
--
|
|
||||||
2.27.0
|
|
||||||
|
|
||||||
@ -1,101 +0,0 @@
|
|||||||
From 3ee9abc7cdd10ccb7057a523326fec21fb01a7bb Mon Sep 17 00:00:00 2001
|
|
||||||
From: fangyi <eric.fangyi@huawei.com>
|
|
||||||
Date: Wed, 22 Nov 2023 09:55:19 +0800
|
|
||||||
Subject: [PATCH] Revert "virtio: add support for configure interrupt"
|
|
||||||
|
|
||||||
This reverts commit 081f864f56307551f59c5e934e3f30a7290d0faa.
|
|
||||||
|
|
||||||
Fixes: 081f864f56 ("virtio: add support for configure interrupt")
|
|
||||||
Cc: "Cindy Lu" <lulu@redhat.com>
|
|
||||||
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
|
|
||||||
Signed-off-by: fangyi <eric.fangyi@huawei.com>
|
|
||||||
---
|
|
||||||
hw/virtio/virtio.c | 29 -----------------------------
|
|
||||||
include/hw/virtio/virtio.h | 4 ----
|
|
||||||
2 files changed, 33 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
|
|
||||||
index 05409b84d1..c1497f59aa 100644
|
|
||||||
--- a/hw/virtio/virtio.c
|
|
||||||
+++ b/hw/virtio/virtio.c
|
|
||||||
@@ -3547,14 +3547,7 @@ static void virtio_queue_guest_notifier_read(EventNotifier *n)
|
|
||||||
virtio_irq(vq);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-static void virtio_config_guest_notifier_read(EventNotifier *n)
|
|
||||||
-{
|
|
||||||
- VirtIODevice *vdev = container_of(n, VirtIODevice, config_notifier);
|
|
||||||
|
|
||||||
- if (event_notifier_test_and_clear(n)) {
|
|
||||||
- virtio_notify_config(vdev);
|
|
||||||
- }
|
|
||||||
-}
|
|
||||||
void virtio_queue_set_guest_notifier_fd_handler(VirtQueue *vq, bool assign,
|
|
||||||
bool with_irqfd)
|
|
||||||
{
|
|
||||||
@@ -3571,23 +3564,6 @@ void virtio_queue_set_guest_notifier_fd_handler(VirtQueue *vq, bool assign,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
-void virtio_config_set_guest_notifier_fd_handler(VirtIODevice *vdev,
|
|
||||||
- bool assign, bool with_irqfd)
|
|
||||||
-{
|
|
||||||
- EventNotifier *n;
|
|
||||||
- n = &vdev->config_notifier;
|
|
||||||
- if (assign && !with_irqfd) {
|
|
||||||
- event_notifier_set_handler(n, virtio_config_guest_notifier_read);
|
|
||||||
- } else {
|
|
||||||
- event_notifier_set_handler(n, NULL);
|
|
||||||
- }
|
|
||||||
- if (!assign) {
|
|
||||||
- /* Test and clear notifier before closing it,*/
|
|
||||||
- /* in case poll callback didn't have time to run. */
|
|
||||||
- virtio_config_guest_notifier_read(n);
|
|
||||||
- }
|
|
||||||
-}
|
|
||||||
-
|
|
||||||
EventNotifier *virtio_queue_get_guest_notifier(VirtQueue *vq)
|
|
||||||
{
|
|
||||||
return &vq->guest_notifier;
|
|
||||||
@@ -3661,11 +3637,6 @@ EventNotifier *virtio_queue_get_host_notifier(VirtQueue *vq)
|
|
||||||
return &vq->host_notifier;
|
|
||||||
}
|
|
||||||
|
|
||||||
-EventNotifier *virtio_config_get_guest_notifier(VirtIODevice *vdev)
|
|
||||||
-{
|
|
||||||
- return &vdev->config_notifier;
|
|
||||||
-}
|
|
||||||
-
|
|
||||||
void virtio_queue_set_host_notifier_enabled(VirtQueue *vq, bool enabled)
|
|
||||||
{
|
|
||||||
vq->host_notifier_enabled = enabled;
|
|
||||||
diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h
|
|
||||||
index 8788ccd1f3..c113a5b864 100644
|
|
||||||
--- a/include/hw/virtio/virtio.h
|
|
||||||
+++ b/include/hw/virtio/virtio.h
|
|
||||||
@@ -112,7 +112,6 @@ struct VirtIODevice
|
|
||||||
bool use_guest_notifier_mask;
|
|
||||||
AddressSpace *dma_as;
|
|
||||||
QLIST_HEAD(, VirtQueue) *vector_queues;
|
|
||||||
- EventNotifier config_notifier;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct VirtioDeviceClass {
|
|
||||||
@@ -316,14 +315,11 @@ uint16_t virtio_get_queue_index(VirtQueue *vq);
|
|
||||||
EventNotifier *virtio_queue_get_guest_notifier(VirtQueue *vq);
|
|
||||||
void virtio_queue_set_guest_notifier_fd_handler(VirtQueue *vq, bool assign,
|
|
||||||
bool with_irqfd);
|
|
||||||
-void virtio_config_set_guest_notifier_fd_handler(VirtIODevice *vdev,
|
|
||||||
- bool assign, bool with_irqfd);
|
|
||||||
int virtio_device_start_ioeventfd(VirtIODevice *vdev);
|
|
||||||
int virtio_device_grab_ioeventfd(VirtIODevice *vdev);
|
|
||||||
void virtio_device_release_ioeventfd(VirtIODevice *vdev);
|
|
||||||
bool virtio_device_ioeventfd_enabled(VirtIODevice *vdev);
|
|
||||||
EventNotifier *virtio_queue_get_host_notifier(VirtQueue *vq);
|
|
||||||
-EventNotifier *virtio_config_get_guest_notifier(VirtIODevice *vdev);
|
|
||||||
void virtio_queue_set_host_notifier_enabled(VirtQueue *vq, bool enabled);
|
|
||||||
void virtio_queue_host_notifier_read(EventNotifier *n);
|
|
||||||
void virtio_queue_aio_set_host_notifier_handler(VirtQueue *vq, AioContext *ctx,
|
|
||||||
--
|
|
||||||
2.27.0
|
|
||||||
|
|
||||||
@ -1,161 +0,0 @@
|
|||||||
From 01e4e3aa5f2e2e44b72e81e76a74821edf2debd3 Mon Sep 17 00:00:00 2001
|
|
||||||
From: fangyi <eric.fangyi@huawei.com>
|
|
||||||
Date: Wed, 22 Nov 2023 10:05:16 +0800
|
|
||||||
Subject: [PATCH] Revert "virtio: introduce macro IRTIO_CONFIG_IRQ_IDX"
|
|
||||||
|
|
||||||
This reverts commit bf1d85c166c19af95dbd27b1faba1d2909732323.
|
|
||||||
|
|
||||||
Fixes: bf1d85c166 ("virtio: introduce macro IRTIO_CONFIG_IRQ_IDX")
|
|
||||||
Cc: "Cindy Lu" <lulu@redhat.com>
|
|
||||||
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
|
|
||||||
Signed-off-by: fangyi <eric.fangyi@huawei.com>
|
|
||||||
---
|
|
||||||
hw/display/vhost-user-gpu.c | 6 ------
|
|
||||||
hw/net/virtio-net.c | 10 ++--------
|
|
||||||
hw/virtio/vhost-user-fs.c | 6 ------
|
|
||||||
hw/virtio/vhost-vsock-common.c | 6 ------
|
|
||||||
hw/virtio/virtio-crypto.c | 6 ------
|
|
||||||
include/hw/virtio/virtio.h | 3 ---
|
|
||||||
6 files changed, 2 insertions(+), 35 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/hw/display/vhost-user-gpu.c b/hw/display/vhost-user-gpu.c
|
|
||||||
index 73ad3d84c9..49df56cd14 100644
|
|
||||||
--- a/hw/display/vhost-user-gpu.c
|
|
||||||
+++ b/hw/display/vhost-user-gpu.c
|
|
||||||
@@ -485,9 +485,6 @@ vhost_user_gpu_guest_notifier_pending(VirtIODevice *vdev, int idx)
|
|
||||||
{
|
|
||||||
VhostUserGPU *g = VHOST_USER_GPU(vdev);
|
|
||||||
|
|
||||||
- if (idx == VIRTIO_CONFIG_IRQ_IDX) {
|
|
||||||
- return false;
|
|
||||||
- }
|
|
||||||
return vhost_virtqueue_pending(&g->vhost->dev, idx);
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -496,9 +493,6 @@ vhost_user_gpu_guest_notifier_mask(VirtIODevice *vdev, int idx, bool mask)
|
|
||||||
{
|
|
||||||
VhostUserGPU *g = VHOST_USER_GPU(vdev);
|
|
||||||
|
|
||||||
- if (idx == VIRTIO_CONFIG_IRQ_IDX) {
|
|
||||||
- return;
|
|
||||||
- }
|
|
||||||
vhost_virtqueue_mask(&g->vhost->dev, vdev, idx, mask);
|
|
||||||
}
|
|
||||||
|
|
||||||
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
|
|
||||||
index 7537f44d10..3bd786cc22 100644
|
|
||||||
--- a/hw/net/virtio-net.c
|
|
||||||
+++ b/hw/net/virtio-net.c
|
|
||||||
@@ -3195,9 +3195,6 @@ static bool virtio_net_guest_notifier_pending(VirtIODevice *vdev, int idx)
|
|
||||||
VirtIONet *n = VIRTIO_NET(vdev);
|
|
||||||
NetClientState *nc = qemu_get_subqueue(n->nic, vq2q(idx));
|
|
||||||
assert(n->vhost_started);
|
|
||||||
- if (idx == VIRTIO_CONFIG_IRQ_IDX) {
|
|
||||||
- return false;
|
|
||||||
- }
|
|
||||||
return vhost_net_virtqueue_pending(get_vhost_net(nc->peer), idx);
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -3207,11 +3204,8 @@ static void virtio_net_guest_notifier_mask(VirtIODevice *vdev, int idx,
|
|
||||||
VirtIONet *n = VIRTIO_NET(vdev);
|
|
||||||
NetClientState *nc = qemu_get_subqueue(n->nic, vq2q(idx));
|
|
||||||
assert(n->vhost_started);
|
|
||||||
- if (idx == VIRTIO_CONFIG_IRQ_IDX) {
|
|
||||||
- return;
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
- vhost_net_virtqueue_mask(get_vhost_net(nc->peer), vdev, idx, mask);
|
|
||||||
+ vhost_net_virtqueue_mask(get_vhost_net(nc->peer),
|
|
||||||
+ vdev, idx, mask);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void virtio_net_set_config_size(VirtIONet *n, uint64_t host_features)
|
|
||||||
diff --git a/hw/virtio/vhost-user-fs.c b/hw/virtio/vhost-user-fs.c
|
|
||||||
index 90c2bc9c5d..fc7dcc96ef 100644
|
|
||||||
--- a/hw/virtio/vhost-user-fs.c
|
|
||||||
+++ b/hw/virtio/vhost-user-fs.c
|
|
||||||
@@ -161,9 +161,6 @@ static void vuf_guest_notifier_mask(VirtIODevice *vdev, int idx,
|
|
||||||
{
|
|
||||||
VHostUserFS *fs = VHOST_USER_FS(vdev);
|
|
||||||
|
|
||||||
- if (idx == VIRTIO_CONFIG_IRQ_IDX) {
|
|
||||||
- return;
|
|
||||||
- }
|
|
||||||
vhost_virtqueue_mask(&fs->vhost_dev, vdev, idx, mask);
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -171,9 +168,6 @@ static bool vuf_guest_notifier_pending(VirtIODevice *vdev, int idx)
|
|
||||||
{
|
|
||||||
VHostUserFS *fs = VHOST_USER_FS(vdev);
|
|
||||||
|
|
||||||
- if (idx == VIRTIO_CONFIG_IRQ_IDX) {
|
|
||||||
- return false;
|
|
||||||
- }
|
|
||||||
return vhost_virtqueue_pending(&fs->vhost_dev, idx);
|
|
||||||
}
|
|
||||||
|
|
||||||
diff --git a/hw/virtio/vhost-vsock-common.c b/hw/virtio/vhost-vsock-common.c
|
|
||||||
index b1f0d46209..ed706681ac 100644
|
|
||||||
--- a/hw/virtio/vhost-vsock-common.c
|
|
||||||
+++ b/hw/virtio/vhost-vsock-common.c
|
|
||||||
@@ -125,9 +125,6 @@ static void vhost_vsock_common_guest_notifier_mask(VirtIODevice *vdev, int idx,
|
|
||||||
{
|
|
||||||
VHostVSockCommon *vvc = VHOST_VSOCK_COMMON(vdev);
|
|
||||||
|
|
||||||
- if (idx == VIRTIO_CONFIG_IRQ_IDX) {
|
|
||||||
- return;
|
|
||||||
- }
|
|
||||||
vhost_virtqueue_mask(&vvc->vhost_dev, vdev, idx, mask);
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -136,9 +133,6 @@ static bool vhost_vsock_common_guest_notifier_pending(VirtIODevice *vdev,
|
|
||||||
{
|
|
||||||
VHostVSockCommon *vvc = VHOST_VSOCK_COMMON(vdev);
|
|
||||||
|
|
||||||
- if (idx == VIRTIO_CONFIG_IRQ_IDX) {
|
|
||||||
- return false;
|
|
||||||
- }
|
|
||||||
return vhost_virtqueue_pending(&vvc->vhost_dev, idx);
|
|
||||||
}
|
|
||||||
|
|
||||||
diff --git a/hw/virtio/virtio-crypto.c b/hw/virtio/virtio-crypto.c
|
|
||||||
index 52ba34ef1e..274c7b4dea 100644
|
|
||||||
--- a/hw/virtio/virtio-crypto.c
|
|
||||||
+++ b/hw/virtio/virtio-crypto.c
|
|
||||||
@@ -953,9 +953,6 @@ static void virtio_crypto_guest_notifier_mask(VirtIODevice *vdev, int idx,
|
|
||||||
|
|
||||||
assert(vcrypto->vhost_started);
|
|
||||||
|
|
||||||
- if (idx == VIRTIO_CONFIG_IRQ_IDX) {
|
|
||||||
- return;
|
|
||||||
- }
|
|
||||||
cryptodev_vhost_virtqueue_mask(vdev, queue, idx, mask);
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -966,9 +963,6 @@ static bool virtio_crypto_guest_notifier_pending(VirtIODevice *vdev, int idx)
|
|
||||||
|
|
||||||
assert(vcrypto->vhost_started);
|
|
||||||
|
|
||||||
- if (idx == VIRTIO_CONFIG_IRQ_IDX) {
|
|
||||||
- return false;
|
|
||||||
- }
|
|
||||||
return cryptodev_vhost_virtqueue_pending(vdev, queue, idx);
|
|
||||||
}
|
|
||||||
|
|
||||||
diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h
|
|
||||||
index c113a5b864..7472145821 100644
|
|
||||||
--- a/include/hw/virtio/virtio.h
|
|
||||||
+++ b/include/hw/virtio/virtio.h
|
|
||||||
@@ -68,9 +68,6 @@ typedef struct VirtQueueElement
|
|
||||||
|
|
||||||
#define VIRTIO_NO_VECTOR 0xffff
|
|
||||||
|
|
||||||
-/* special index value used internally for config irqs */
|
|
||||||
-#define VIRTIO_CONFIG_IRQ_IDX -1
|
|
||||||
-
|
|
||||||
#define TYPE_VIRTIO_DEVICE "virtio-device"
|
|
||||||
OBJECT_DECLARE_TYPE(VirtIODevice, VirtioDeviceClass, VIRTIO_DEVICE)
|
|
||||||
|
|
||||||
--
|
|
||||||
2.27.0
|
|
||||||
|
|
||||||
@ -1,64 +0,0 @@
|
|||||||
From 9633634fe4395000e88c8ab829ec756c7132d3bf Mon Sep 17 00:00:00 2001
|
|
||||||
From: fangyi <eric.fangyi@huawei.com>
|
|
||||||
Date: Wed, 22 Nov 2023 09:48:17 +0800
|
|
||||||
Subject: [PATCH] Revert "virtio-mmio: add support for configure interrupt"
|
|
||||||
|
|
||||||
This reverts commit d48185f1a40d4e4ed2fa2873a42b2a5eb8748256.
|
|
||||||
|
|
||||||
Fixes: d48185f1a4 ("virtio-mmio: add support for configure interrupt")
|
|
||||||
Cc: "Cindy Lu" <lulu@redhat.com>
|
|
||||||
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
|
|
||||||
Signed-off-by: fangyi <eric.fangyi@huawei.com>
|
|
||||||
---
|
|
||||||
hw/virtio/virtio-mmio.c | 27 ---------------------------
|
|
||||||
1 file changed, 27 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/hw/virtio/virtio-mmio.c b/hw/virtio/virtio-mmio.c
|
|
||||||
index 809132018b..72da12fea5 100644
|
|
||||||
--- a/hw/virtio/virtio-mmio.c
|
|
||||||
+++ b/hw/virtio/virtio-mmio.c
|
|
||||||
@@ -673,30 +673,7 @@ static int virtio_mmio_set_guest_notifier(DeviceState *d, int n, bool assign,
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
-static int virtio_mmio_set_config_guest_notifier(DeviceState *d, bool assign)
|
|
||||||
-{
|
|
||||||
- VirtIOMMIOProxy *proxy = VIRTIO_MMIO(d);
|
|
||||||
- VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);
|
|
||||||
- VirtioDeviceClass *vdc = VIRTIO_DEVICE_GET_CLASS(vdev);
|
|
||||||
- bool with_irqfd = false;
|
|
||||||
- EventNotifier *notifier = virtio_config_get_guest_notifier(vdev);
|
|
||||||
- int r = 0;
|
|
||||||
|
|
||||||
- if (assign) {
|
|
||||||
- r = event_notifier_init(notifier, 0);
|
|
||||||
- if (r < 0) {
|
|
||||||
- return r;
|
|
||||||
- }
|
|
||||||
- virtio_config_set_guest_notifier_fd_handler(vdev, assign, with_irqfd);
|
|
||||||
- } else {
|
|
||||||
- virtio_config_set_guest_notifier_fd_handler(vdev, assign, with_irqfd);
|
|
||||||
- event_notifier_cleanup(notifier);
|
|
||||||
- }
|
|
||||||
- if (vdc->guest_notifier_mask && vdev->use_guest_notifier_mask) {
|
|
||||||
- vdc->guest_notifier_mask(vdev, VIRTIO_CONFIG_IRQ_IDX, !assign);
|
|
||||||
- }
|
|
||||||
- return r;
|
|
||||||
-}
|
|
||||||
static int virtio_mmio_set_guest_notifiers(DeviceState *d, int nvqs,
|
|
||||||
bool assign)
|
|
||||||
{
|
|
||||||
@@ -718,10 +695,6 @@ static int virtio_mmio_set_guest_notifiers(DeviceState *d, int nvqs,
|
|
||||||
goto assign_error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
- r = virtio_mmio_set_config_guest_notifier(d, assign);
|
|
||||||
- if (r < 0) {
|
|
||||||
- goto assign_error;
|
|
||||||
- }
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
--
|
|
||||||
2.27.0
|
|
||||||
|
|
||||||
@ -1,52 +0,0 @@
|
|||||||
From 4f6f9e62214a008523b054c82d663d14d82a2c86 Mon Sep 17 00:00:00 2001
|
|
||||||
From: fangyi <eric.fangyi@huawei.com>
|
|
||||||
Date: Wed, 22 Nov 2023 09:50:43 +0800
|
|
||||||
Subject: [PATCH] Revert "virtio-net: add support for configure interrupt"
|
|
||||||
|
|
||||||
This reverts commit 497679d51087090d5a22fd265d1b96cf92d49d9d.
|
|
||||||
|
|
||||||
Fixes: 497679d510 ("virtio-net: add support for configure interrupt")
|
|
||||||
Cc: "Cindy Lu" <lulu@redhat.com>
|
|
||||||
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
|
|
||||||
Signed-off-by: fangyi <eric.fangyi@huawei.com>
|
|
||||||
---
|
|
||||||
hw/net/vhost_net.c | 9 ---------
|
|
||||||
include/net/vhost_net.h | 2 --
|
|
||||||
2 files changed, 11 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c
|
|
||||||
index d5a92144bb..bea053a742 100644
|
|
||||||
--- a/hw/net/vhost_net.c
|
|
||||||
+++ b/hw/net/vhost_net.c
|
|
||||||
@@ -524,15 +524,6 @@ void vhost_net_virtqueue_mask(VHostNetState *net, VirtIODevice *dev,
|
|
||||||
vhost_virtqueue_mask(&net->dev, dev, idx, mask);
|
|
||||||
}
|
|
||||||
|
|
||||||
-bool vhost_net_config_pending(VHostNetState *net)
|
|
||||||
-{
|
|
||||||
- return vhost_config_pending(&net->dev);
|
|
||||||
-}
|
|
||||||
-
|
|
||||||
-void vhost_net_config_mask(VHostNetState *net, VirtIODevice *dev, bool mask)
|
|
||||||
-{
|
|
||||||
- vhost_config_mask(&net->dev, dev, mask);
|
|
||||||
-}
|
|
||||||
VHostNetState *get_vhost_net(NetClientState *nc)
|
|
||||||
{
|
|
||||||
VHostNetState *vhost_net = 0;
|
|
||||||
diff --git a/include/net/vhost_net.h b/include/net/vhost_net.h
|
|
||||||
index 1844f0ed46..7bdbf484e4 100644
|
|
||||||
--- a/include/net/vhost_net.h
|
|
||||||
+++ b/include/net/vhost_net.h
|
|
||||||
@@ -39,8 +39,6 @@ int vhost_net_set_config(struct vhost_net *net, const uint8_t *data,
|
|
||||||
bool vhost_net_virtqueue_pending(VHostNetState *net, int n);
|
|
||||||
void vhost_net_virtqueue_mask(VHostNetState *net, VirtIODevice *dev,
|
|
||||||
int idx, bool mask);
|
|
||||||
-bool vhost_net_config_pending(VHostNetState *net);
|
|
||||||
-void vhost_net_config_mask(VHostNetState *net, VirtIODevice *dev, bool mask);
|
|
||||||
int vhost_net_notify_migration_done(VHostNetState *net, char* mac_addr);
|
|
||||||
VHostNetState *get_vhost_net(NetClientState *nc);
|
|
||||||
|
|
||||||
--
|
|
||||||
2.27.0
|
|
||||||
|
|
||||||
@ -1,215 +0,0 @@
|
|||||||
From b97597030e537248f3986589cfc4a32a3e7eb8f5 Mon Sep 17 00:00:00 2001
|
|
||||||
From: fangyi <eric.fangyi@huawei.com>
|
|
||||||
Date: Wed, 22 Nov 2023 09:46:06 +0800
|
|
||||||
Subject: [PATCH] Revert "virtio-pci: add support for configure interrupt"
|
|
||||||
|
|
||||||
This reverts commit d5d24d859c3957ea1674d0e102f96439cdbfe93a.
|
|
||||||
|
|
||||||
Fixes: d5d24d859c ("virtio-pci: add support for configure interrupt")
|
|
||||||
Cc: "Cindy Lu" <lulu@redhat.com>
|
|
||||||
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
|
|
||||||
Signed-off-by: fangyi <eric.fangyi@huawei.com>
|
|
||||||
---
|
|
||||||
hw/virtio/virtio-pci.c | 92 ++++++------------------------------------
|
|
||||||
hw/virtio/virtio-pci.h | 4 +-
|
|
||||||
2 files changed, 13 insertions(+), 83 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
|
|
||||||
index 90237f523e..75be770971 100644
|
|
||||||
--- a/hw/virtio/virtio-pci.c
|
|
||||||
+++ b/hw/virtio/virtio-pci.c
|
|
||||||
@@ -812,8 +812,7 @@ static int virtio_pci_get_notifier(VirtIOPCIProxy *proxy, int queue_no,
|
|
||||||
VirtQueue *vq;
|
|
||||||
|
|
||||||
if (queue_no == VIRTIO_CONFIG_IRQ_IDX) {
|
|
||||||
- *n = virtio_config_get_guest_notifier(vdev);
|
|
||||||
- *vector = vdev->config_vector;
|
|
||||||
+ return -1;
|
|
||||||
} else {
|
|
||||||
if (!virtio_queue_get_num(vdev, queue_no)) {
|
|
||||||
return -1;
|
|
||||||
@@ -888,10 +887,6 @@ static int kvm_virtio_pci_vector_use(VirtIOPCIProxy *proxy, int nvqs)
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
-static int kvm_virtio_pci_vector_config_use(VirtIOPCIProxy *proxy)
|
|
||||||
-{
|
|
||||||
- return kvm_virtio_pci_vector_use_one(proxy, VIRTIO_CONFIG_IRQ_IDX);
|
|
||||||
-}
|
|
||||||
|
|
||||||
static void kvm_virtio_pci_vector_release_one(VirtIOPCIProxy *proxy,
|
|
||||||
int queue_no)
|
|
||||||
@@ -929,11 +924,6 @@ static void kvm_virtio_pci_vector_release(VirtIOPCIProxy *proxy, int nvqs)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
-static void kvm_virtio_pci_vector_config_release(VirtIOPCIProxy *proxy)
|
|
||||||
-{
|
|
||||||
- kvm_virtio_pci_vector_release_one(proxy, VIRTIO_CONFIG_IRQ_IDX);
|
|
||||||
-}
|
|
||||||
-
|
|
||||||
static int virtio_pci_one_vector_unmask(VirtIOPCIProxy *proxy,
|
|
||||||
unsigned int queue_no,
|
|
||||||
unsigned int vector,
|
|
||||||
@@ -1015,17 +1005,9 @@ static int virtio_pci_vector_unmask(PCIDevice *dev, unsigned vector,
|
|
||||||
}
|
|
||||||
vq = virtio_vector_next_queue(vq);
|
|
||||||
}
|
|
||||||
- /* unmask config intr */
|
|
||||||
- n = virtio_config_get_guest_notifier(vdev);
|
|
||||||
- ret = virtio_pci_one_vector_unmask(proxy, VIRTIO_CONFIG_IRQ_IDX, vector,
|
|
||||||
- msg, n);
|
|
||||||
- if (ret < 0) {
|
|
||||||
- goto undo_config;
|
|
||||||
- }
|
|
||||||
+
|
|
||||||
return 0;
|
|
||||||
-undo_config:
|
|
||||||
- n = virtio_config_get_guest_notifier(vdev);
|
|
||||||
- virtio_pci_one_vector_mask(proxy, VIRTIO_CONFIG_IRQ_IDX, vector, n);
|
|
||||||
+
|
|
||||||
undo:
|
|
||||||
vq = virtio_vector_first_queue(vdev, vector);
|
|
||||||
while (vq && unmasked >= 0) {
|
|
||||||
@@ -1059,8 +1041,6 @@ static void virtio_pci_vector_mask(PCIDevice *dev, unsigned vector)
|
|
||||||
}
|
|
||||||
vq = virtio_vector_next_queue(vq);
|
|
||||||
}
|
|
||||||
- n = virtio_config_get_guest_notifier(vdev);
|
|
||||||
- virtio_pci_one_vector_mask(proxy, VIRTIO_CONFIG_IRQ_IDX, vector, n);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void virtio_pci_vector_poll(PCIDevice *dev,
|
|
||||||
@@ -1092,34 +1072,6 @@ static void virtio_pci_vector_poll(PCIDevice *dev,
|
|
||||||
msix_set_pending(dev, vector);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
- /* poll the config intr */
|
|
||||||
- ret = virtio_pci_get_notifier(proxy, VIRTIO_CONFIG_IRQ_IDX, ¬ifier,
|
|
||||||
- &vector);
|
|
||||||
- if (ret < 0) {
|
|
||||||
- return;
|
|
||||||
- }
|
|
||||||
- if (vector < vector_start || vector >= vector_end ||
|
|
||||||
- !msix_is_masked(dev, vector)) {
|
|
||||||
- return;
|
|
||||||
- }
|
|
||||||
- if (k->guest_notifier_pending) {
|
|
||||||
- if (k->guest_notifier_pending(vdev, VIRTIO_CONFIG_IRQ_IDX)) {
|
|
||||||
- msix_set_pending(dev, vector);
|
|
||||||
- }
|
|
||||||
- } else if (event_notifier_test_and_clear(notifier)) {
|
|
||||||
- msix_set_pending(dev, vector);
|
|
||||||
- }
|
|
||||||
-}
|
|
||||||
-
|
|
||||||
-void virtio_pci_set_guest_notifier_fd_handler(VirtIODevice *vdev, VirtQueue *vq,
|
|
||||||
- int n, bool assign,
|
|
||||||
- bool with_irqfd)
|
|
||||||
-{
|
|
||||||
- if (n == VIRTIO_CONFIG_IRQ_IDX) {
|
|
||||||
- virtio_config_set_guest_notifier_fd_handler(vdev, assign, with_irqfd);
|
|
||||||
- } else {
|
|
||||||
- virtio_queue_set_guest_notifier_fd_handler(vq, assign, with_irqfd);
|
|
||||||
- }
|
|
||||||
}
|
|
||||||
|
|
||||||
static int virtio_pci_set_guest_notifier(DeviceState *d, int n, bool assign,
|
|
||||||
@@ -1128,25 +1080,17 @@ static int virtio_pci_set_guest_notifier(DeviceState *d, int n, bool assign,
|
|
||||||
VirtIOPCIProxy *proxy = to_virtio_pci_proxy(d);
|
|
||||||
VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);
|
|
||||||
VirtioDeviceClass *vdc = VIRTIO_DEVICE_GET_CLASS(vdev);
|
|
||||||
- VirtQueue *vq = NULL;
|
|
||||||
- EventNotifier *notifier = NULL;
|
|
||||||
-
|
|
||||||
- if (n == VIRTIO_CONFIG_IRQ_IDX) {
|
|
||||||
- notifier = virtio_config_get_guest_notifier(vdev);
|
|
||||||
- } else {
|
|
||||||
- vq = virtio_get_queue(vdev, n);
|
|
||||||
- notifier = virtio_queue_get_guest_notifier(vq);
|
|
||||||
- }
|
|
||||||
+ VirtQueue *vq = virtio_get_queue(vdev, n);
|
|
||||||
+ EventNotifier *notifier = virtio_queue_get_guest_notifier(vq);
|
|
||||||
|
|
||||||
if (assign) {
|
|
||||||
int r = event_notifier_init(notifier, 0);
|
|
||||||
if (r < 0) {
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
- virtio_pci_set_guest_notifier_fd_handler(vdev, vq, n, true, with_irqfd);
|
|
||||||
+ virtio_queue_set_guest_notifier_fd_handler(vq, true, with_irqfd);
|
|
||||||
} else {
|
|
||||||
- virtio_pci_set_guest_notifier_fd_handler(vdev, vq, n, false,
|
|
||||||
- with_irqfd);
|
|
||||||
+ virtio_queue_set_guest_notifier_fd_handler(vq, false, with_irqfd);
|
|
||||||
event_notifier_cleanup(notifier);
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1188,7 +1132,6 @@ static int virtio_pci_set_guest_notifiers(DeviceState *d, int nvqs, bool assign)
|
|
||||||
msix_unset_vector_notifiers(&proxy->pci_dev);
|
|
||||||
if (proxy->vector_irqfd) {
|
|
||||||
kvm_virtio_pci_vector_release(proxy, nvqs);
|
|
||||||
- kvm_virtio_pci_vector_config_release(proxy);
|
|
||||||
g_free(proxy->vector_irqfd);
|
|
||||||
proxy->vector_irqfd = NULL;
|
|
||||||
}
|
|
||||||
@@ -1204,11 +1147,7 @@ static int virtio_pci_set_guest_notifiers(DeviceState *d, int nvqs, bool assign)
|
|
||||||
goto assign_error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
- r = virtio_pci_set_guest_notifier(d, VIRTIO_CONFIG_IRQ_IDX, assign,
|
|
||||||
- with_irqfd);
|
|
||||||
- if (r < 0) {
|
|
||||||
- goto config_assign_error;
|
|
||||||
- }
|
|
||||||
+
|
|
||||||
/* Must set vector notifier after guest notifier has been assigned */
|
|
||||||
if ((with_irqfd || k->guest_notifier_mask) && assign) {
|
|
||||||
if (with_irqfd) {
|
|
||||||
@@ -1217,14 +1156,11 @@ static int virtio_pci_set_guest_notifiers(DeviceState *d, int nvqs, bool assign)
|
|
||||||
msix_nr_vectors_allocated(&proxy->pci_dev));
|
|
||||||
r = kvm_virtio_pci_vector_use(proxy, nvqs);
|
|
||||||
if (r < 0) {
|
|
||||||
- goto config_assign_error;
|
|
||||||
+ goto assign_error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
- r = kvm_virtio_pci_vector_config_use(proxy);
|
|
||||||
- if (r < 0) {
|
|
||||||
- goto config_error;
|
|
||||||
- }
|
|
||||||
- r = msix_set_vector_notifiers(&proxy->pci_dev, virtio_pci_vector_unmask,
|
|
||||||
+ r = msix_set_vector_notifiers(&proxy->pci_dev,
|
|
||||||
+ virtio_pci_vector_unmask,
|
|
||||||
virtio_pci_vector_mask,
|
|
||||||
virtio_pci_vector_poll);
|
|
||||||
if (r < 0) {
|
|
||||||
@@ -1239,11 +1175,7 @@ notifiers_error:
|
|
||||||
assert(assign);
|
|
||||||
kvm_virtio_pci_vector_release(proxy, nvqs);
|
|
||||||
}
|
|
||||||
-config_error:
|
|
||||||
- kvm_virtio_pci_vector_config_release(proxy);
|
|
||||||
-config_assign_error:
|
|
||||||
- virtio_pci_set_guest_notifier(d, VIRTIO_CONFIG_IRQ_IDX, !assign,
|
|
||||||
- with_irqfd);
|
|
||||||
+
|
|
||||||
assign_error:
|
|
||||||
/* We get here on assignment failure. Recover by undoing for VQs 0 .. n. */
|
|
||||||
assert(assign);
|
|
||||||
diff --git a/hw/virtio/virtio-pci.h b/hw/virtio/virtio-pci.h
|
|
||||||
index 6d8e071d8d..d95b1a13a5 100644
|
|
||||||
--- a/hw/virtio/virtio-pci.h
|
|
||||||
+++ b/hw/virtio/virtio-pci.h
|
|
||||||
@@ -256,7 +256,5 @@ void virtio_pci_types_register(const VirtioPCIDeviceTypeInfo *t);
|
|
||||||
* @fixed_queues.
|
|
||||||
*/
|
|
||||||
unsigned virtio_pci_optimal_num_queues(unsigned fixed_queues);
|
|
||||||
-void virtio_pci_set_guest_notifier_fd_handler(VirtIODevice *vdev, VirtQueue *vq,
|
|
||||||
- int n, bool assign,
|
|
||||||
- bool with_irqfd);
|
|
||||||
+
|
|
||||||
#endif
|
|
||||||
--
|
|
||||||
2.27.0
|
|
||||||
|
|
||||||
@ -1,255 +0,0 @@
|
|||||||
From 38c0a07985c6616c43ee98caf7054ddd49dcd34e Mon Sep 17 00:00:00 2001
|
|
||||||
From: fangyi <eric.fangyi@huawei.com>
|
|
||||||
Date: Wed, 22 Nov 2023 10:02:59 +0800
|
|
||||||
Subject: [PATCH] Revert "virtio-pci: decouple notifier from interrupt process"
|
|
||||||
|
|
||||||
This reverts commit e3480ef81f6fb61cc9c04e3b5be8b7e84484fc05.
|
|
||||||
|
|
||||||
Fixes: e3480ef81f ("virtio-pci: decouple notifier from interrupt process")
|
|
||||||
Cc: "Cindy Lu" <lulu@redhat.com>
|
|
||||||
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
|
|
||||||
Signed-off-by: fangyi <eric.fangyi@huawei.com>
|
|
||||||
---
|
|
||||||
hw/virtio/virtio-pci.c | 88 +++++++++++++++---------------------------
|
|
||||||
1 file changed, 31 insertions(+), 57 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
|
|
||||||
index 85d7357f66..21c0ec3b1b 100644
|
|
||||||
--- a/hw/virtio/virtio-pci.c
|
|
||||||
+++ b/hw/virtio/virtio-pci.c
|
|
||||||
@@ -789,41 +789,29 @@ static void kvm_virtio_pci_vq_vector_release(VirtIOPCIProxy *proxy,
|
|
||||||
}
|
|
||||||
|
|
||||||
static int kvm_virtio_pci_irqfd_use(VirtIOPCIProxy *proxy,
|
|
||||||
- EventNotifier *n,
|
|
||||||
+ unsigned int queue_no,
|
|
||||||
unsigned int vector)
|
|
||||||
{
|
|
||||||
VirtIOIRQFD *irqfd = &proxy->vector_irqfd[vector];
|
|
||||||
+ VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);
|
|
||||||
+ VirtQueue *vq = virtio_get_queue(vdev, queue_no);
|
|
||||||
+ EventNotifier *n = virtio_queue_get_guest_notifier(vq);
|
|
||||||
return kvm_irqchip_add_irqfd_notifier_gsi(kvm_state, n, NULL, irqfd->virq);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void kvm_virtio_pci_irqfd_release(VirtIOPCIProxy *proxy,
|
|
||||||
- EventNotifier *n ,
|
|
||||||
+ unsigned int queue_no,
|
|
||||||
unsigned int vector)
|
|
||||||
{
|
|
||||||
+ VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);
|
|
||||||
+ VirtQueue *vq = virtio_get_queue(vdev, queue_no);
|
|
||||||
+ EventNotifier *n = virtio_queue_get_guest_notifier(vq);
|
|
||||||
VirtIOIRQFD *irqfd = &proxy->vector_irqfd[vector];
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
ret = kvm_irqchip_remove_irqfd_notifier_gsi(kvm_state, n, irqfd->virq);
|
|
||||||
assert(ret == 0);
|
|
||||||
}
|
|
||||||
-static int virtio_pci_get_notifier(VirtIOPCIProxy *proxy, int queue_no,
|
|
||||||
- EventNotifier **n, unsigned int *vector)
|
|
||||||
-{
|
|
||||||
- VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);
|
|
||||||
- VirtQueue *vq;
|
|
||||||
-
|
|
||||||
- if (queue_no == VIRTIO_CONFIG_IRQ_IDX) {
|
|
||||||
- return -1;
|
|
||||||
- } else {
|
|
||||||
- if (!virtio_queue_get_num(vdev, queue_no)) {
|
|
||||||
- return -1;
|
|
||||||
- }
|
|
||||||
- *vector = virtio_queue_vector(vdev, queue_no);
|
|
||||||
- vq = virtio_get_queue(vdev, queue_no);
|
|
||||||
- *n = virtio_queue_get_guest_notifier(vq);
|
|
||||||
- }
|
|
||||||
- return 0;
|
|
||||||
-}
|
|
||||||
|
|
||||||
static int kvm_virtio_pci_vector_use(VirtIOPCIProxy *proxy, int nvqs)
|
|
||||||
{
|
|
||||||
@@ -832,15 +820,12 @@ static int kvm_virtio_pci_vector_use(VirtIOPCIProxy *proxy, int nvqs)
|
|
||||||
VirtioDeviceClass *k = VIRTIO_DEVICE_GET_CLASS(vdev);
|
|
||||||
unsigned int vector;
|
|
||||||
int ret, queue_no;
|
|
||||||
- EventNotifier *n;
|
|
||||||
+
|
|
||||||
for (queue_no = 0; queue_no < nvqs; queue_no++) {
|
|
||||||
if (!virtio_queue_get_num(vdev, queue_no)) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
- ret = virtio_pci_get_notifier(proxy, queue_no, &n, &vector);
|
|
||||||
- if (ret < 0) {
|
|
||||||
- break;
|
|
||||||
- }
|
|
||||||
+ vector = virtio_queue_vector(vdev, queue_no);
|
|
||||||
if (vector >= msix_nr_vectors_allocated(dev)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
@@ -852,7 +837,7 @@ static int kvm_virtio_pci_vector_use(VirtIOPCIProxy *proxy, int nvqs)
|
|
||||||
* Otherwise, delay until unmasked in the frontend.
|
|
||||||
*/
|
|
||||||
if (vdev->use_guest_notifier_mask && k->guest_notifier_mask) {
|
|
||||||
- ret = kvm_virtio_pci_irqfd_use(proxy, n, vector);
|
|
||||||
+ ret = kvm_virtio_pci_irqfd_use(proxy, queue_no, vector);
|
|
||||||
if (ret < 0) {
|
|
||||||
kvm_virtio_pci_vq_vector_release(proxy, vector);
|
|
||||||
goto undo;
|
|
||||||
@@ -868,11 +853,7 @@ undo:
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (vdev->use_guest_notifier_mask && k->guest_notifier_mask) {
|
|
||||||
- ret = virtio_pci_get_notifier(proxy, queue_no, &n, &vector);
|
|
||||||
- if (ret < 0) {
|
|
||||||
- break;
|
|
||||||
- }
|
|
||||||
- kvm_virtio_pci_irqfd_release(proxy, n, vector);
|
|
||||||
+ kvm_virtio_pci_irqfd_release(proxy, queue_no, vector);
|
|
||||||
}
|
|
||||||
kvm_virtio_pci_vq_vector_release(proxy, vector);
|
|
||||||
}
|
|
||||||
@@ -886,16 +867,12 @@ static void kvm_virtio_pci_vector_release(VirtIOPCIProxy *proxy, int nvqs)
|
|
||||||
unsigned int vector;
|
|
||||||
int queue_no;
|
|
||||||
VirtioDeviceClass *k = VIRTIO_DEVICE_GET_CLASS(vdev);
|
|
||||||
- EventNotifier *n;
|
|
||||||
- int ret ;
|
|
||||||
+
|
|
||||||
for (queue_no = 0; queue_no < nvqs; queue_no++) {
|
|
||||||
if (!virtio_queue_get_num(vdev, queue_no)) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
- ret = virtio_pci_get_notifier(proxy, queue_no, &n, &vector);
|
|
||||||
- if (ret < 0) {
|
|
||||||
- break;
|
|
||||||
- }
|
|
||||||
+ vector = virtio_queue_vector(vdev, queue_no);
|
|
||||||
if (vector >= msix_nr_vectors_allocated(dev)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
@@ -903,20 +880,21 @@ static void kvm_virtio_pci_vector_release(VirtIOPCIProxy *proxy, int nvqs)
|
|
||||||
* Otherwise, it was cleaned when masked in the frontend.
|
|
||||||
*/
|
|
||||||
if (vdev->use_guest_notifier_mask && k->guest_notifier_mask) {
|
|
||||||
- kvm_virtio_pci_irqfd_release(proxy, n, vector);
|
|
||||||
+ kvm_virtio_pci_irqfd_release(proxy, queue_no, vector);
|
|
||||||
}
|
|
||||||
kvm_virtio_pci_vq_vector_release(proxy, vector);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
-static int virtio_pci_one_vector_unmask(VirtIOPCIProxy *proxy,
|
|
||||||
+static int virtio_pci_vq_vector_unmask(VirtIOPCIProxy *proxy,
|
|
||||||
unsigned int queue_no,
|
|
||||||
unsigned int vector,
|
|
||||||
- MSIMessage msg,
|
|
||||||
- EventNotifier *n)
|
|
||||||
+ MSIMessage msg)
|
|
||||||
{
|
|
||||||
VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);
|
|
||||||
VirtioDeviceClass *k = VIRTIO_DEVICE_GET_CLASS(vdev);
|
|
||||||
+ VirtQueue *vq = virtio_get_queue(vdev, queue_no);
|
|
||||||
+ EventNotifier *n = virtio_queue_get_guest_notifier(vq);
|
|
||||||
VirtIOIRQFD *irqfd;
|
|
||||||
int ret = 0;
|
|
||||||
|
|
||||||
@@ -943,15 +921,14 @@ static int virtio_pci_one_vector_unmask(VirtIOPCIProxy *proxy,
|
|
||||||
event_notifier_set(n);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
- ret = kvm_virtio_pci_irqfd_use(proxy, n, vector);
|
|
||||||
+ ret = kvm_virtio_pci_irqfd_use(proxy, queue_no, vector);
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
-static void virtio_pci_one_vector_mask(VirtIOPCIProxy *proxy,
|
|
||||||
+static void virtio_pci_vq_vector_mask(VirtIOPCIProxy *proxy,
|
|
||||||
unsigned int queue_no,
|
|
||||||
- unsigned int vector,
|
|
||||||
- EventNotifier *n)
|
|
||||||
+ unsigned int vector)
|
|
||||||
{
|
|
||||||
VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);
|
|
||||||
VirtioDeviceClass *k = VIRTIO_DEVICE_GET_CLASS(vdev);
|
|
||||||
@@ -962,7 +939,7 @@ static void virtio_pci_one_vector_mask(VirtIOPCIProxy *proxy,
|
|
||||||
if (vdev->use_guest_notifier_mask && k->guest_notifier_mask) {
|
|
||||||
k->guest_notifier_mask(vdev, queue_no, true);
|
|
||||||
} else {
|
|
||||||
- kvm_virtio_pci_irqfd_release(proxy, n, vector);
|
|
||||||
+ kvm_virtio_pci_irqfd_release(proxy, queue_no, vector);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -972,7 +949,6 @@ static int virtio_pci_vector_unmask(PCIDevice *dev, unsigned vector,
|
|
||||||
VirtIOPCIProxy *proxy = container_of(dev, VirtIOPCIProxy, pci_dev);
|
|
||||||
VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);
|
|
||||||
VirtQueue *vq = virtio_vector_first_queue(vdev, vector);
|
|
||||||
- EventNotifier *n;
|
|
||||||
int ret, index, unmasked = 0;
|
|
||||||
|
|
||||||
while (vq) {
|
|
||||||
@@ -981,8 +957,7 @@ static int virtio_pci_vector_unmask(PCIDevice *dev, unsigned vector,
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (index < proxy->nvqs_with_notifiers) {
|
|
||||||
- n = virtio_queue_get_guest_notifier(vq);
|
|
||||||
- ret = virtio_pci_one_vector_unmask(proxy, index, vector, msg, n);
|
|
||||||
+ ret = virtio_pci_vq_vector_unmask(proxy, index, vector, msg);
|
|
||||||
if (ret < 0) {
|
|
||||||
goto undo;
|
|
||||||
}
|
|
||||||
@@ -998,8 +973,7 @@ undo:
|
|
||||||
while (vq && unmasked >= 0) {
|
|
||||||
index = virtio_get_queue_index(vq);
|
|
||||||
if (index < proxy->nvqs_with_notifiers) {
|
|
||||||
- n = virtio_queue_get_guest_notifier(vq);
|
|
||||||
- virtio_pci_one_vector_mask(proxy, index, vector, n);
|
|
||||||
+ virtio_pci_vq_vector_mask(proxy, index, vector);
|
|
||||||
--unmasked;
|
|
||||||
}
|
|
||||||
vq = virtio_vector_next_queue(vq);
|
|
||||||
@@ -1012,17 +986,15 @@ static void virtio_pci_vector_mask(PCIDevice *dev, unsigned vector)
|
|
||||||
VirtIOPCIProxy *proxy = container_of(dev, VirtIOPCIProxy, pci_dev);
|
|
||||||
VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);
|
|
||||||
VirtQueue *vq = virtio_vector_first_queue(vdev, vector);
|
|
||||||
- EventNotifier *n;
|
|
||||||
int index;
|
|
||||||
|
|
||||||
while (vq) {
|
|
||||||
index = virtio_get_queue_index(vq);
|
|
||||||
- n = virtio_queue_get_guest_notifier(vq);
|
|
||||||
if (!virtio_queue_get_num(vdev, index)) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (index < proxy->nvqs_with_notifiers) {
|
|
||||||
- virtio_pci_one_vector_mask(proxy, index, vector, n);
|
|
||||||
+ virtio_pci_vq_vector_mask(proxy, index, vector);
|
|
||||||
}
|
|
||||||
vq = virtio_vector_next_queue(vq);
|
|
||||||
}
|
|
||||||
@@ -1038,17 +1010,19 @@ static void virtio_pci_vector_poll(PCIDevice *dev,
|
|
||||||
int queue_no;
|
|
||||||
unsigned int vector;
|
|
||||||
EventNotifier *notifier;
|
|
||||||
- int ret;
|
|
||||||
+ VirtQueue *vq;
|
|
||||||
|
|
||||||
for (queue_no = 0; queue_no < proxy->nvqs_with_notifiers; queue_no++) {
|
|
||||||
- ret = virtio_pci_get_notifier(proxy, queue_no, ¬ifier, &vector);
|
|
||||||
- if (ret < 0) {
|
|
||||||
+ if (!virtio_queue_get_num(vdev, queue_no)) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
+ vector = virtio_queue_vector(vdev, queue_no);
|
|
||||||
if (vector < vector_start || vector >= vector_end ||
|
|
||||||
!msix_is_masked(dev, vector)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
+ vq = virtio_get_queue(vdev, queue_no);
|
|
||||||
+ notifier = virtio_queue_get_guest_notifier(vq);
|
|
||||||
if (k->guest_notifier_pending) {
|
|
||||||
if (k->guest_notifier_pending(vdev, queue_no)) {
|
|
||||||
msix_set_pending(dev, vector);
|
|
||||||
--
|
|
||||||
2.27.0
|
|
||||||
|
|
||||||
@ -1,192 +0,0 @@
|
|||||||
From 074043d5d6c2610a320d2bc7d8649b7eff9c806e Mon Sep 17 00:00:00 2001
|
|
||||||
From: fangyi <eric.fangyi@huawei.com>
|
|
||||||
Date: Wed, 22 Nov 2023 10:01:17 +0800
|
|
||||||
Subject: [PATCH] Revert "virtio-pci: decouple the single vector from the
|
|
||||||
interrupt process"
|
|
||||||
|
|
||||||
This reverts commit 316011b8a74e777eb3ba03171cd701a291c28867.
|
|
||||||
|
|
||||||
Fixes: 316011b8a7 ("virtio-pci: decouple the single vector from the interrupt process")
|
|
||||||
Cc: "Cindy Lu" <lulu@redhat.com>
|
|
||||||
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
|
|
||||||
Signed-off-by: fangyi <eric.fangyi@huawei.com>
|
|
||||||
---
|
|
||||||
hw/virtio/virtio-pci.c | 131 ++++++++++++++++++-----------------------
|
|
||||||
1 file changed, 58 insertions(+), 73 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
|
|
||||||
index 75be770971..85d7357f66 100644
|
|
||||||
--- a/hw/virtio/virtio-pci.c
|
|
||||||
+++ b/hw/virtio/virtio-pci.c
|
|
||||||
@@ -762,6 +762,7 @@ static uint32_t virtio_read_config(PCIDevice *pci_dev,
|
|
||||||
}
|
|
||||||
|
|
||||||
static int kvm_virtio_pci_vq_vector_use(VirtIOPCIProxy *proxy,
|
|
||||||
+ unsigned int queue_no,
|
|
||||||
unsigned int vector)
|
|
||||||
{
|
|
||||||
VirtIOIRQFD *irqfd = &proxy->vector_irqfd[vector];
|
|
||||||
@@ -824,103 +825,87 @@ static int virtio_pci_get_notifier(VirtIOPCIProxy *proxy, int queue_no,
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
-static int kvm_virtio_pci_vector_use_one(VirtIOPCIProxy *proxy, int queue_no)
|
|
||||||
+static int kvm_virtio_pci_vector_use(VirtIOPCIProxy *proxy, int nvqs)
|
|
||||||
{
|
|
||||||
- unsigned int vector;
|
|
||||||
- int ret;
|
|
||||||
- EventNotifier *n;
|
|
||||||
PCIDevice *dev = &proxy->pci_dev;
|
|
||||||
VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);
|
|
||||||
VirtioDeviceClass *k = VIRTIO_DEVICE_GET_CLASS(vdev);
|
|
||||||
-
|
|
||||||
- ret = virtio_pci_get_notifier(proxy, queue_no, &n, &vector);
|
|
||||||
- if (ret < 0) {
|
|
||||||
- return ret;
|
|
||||||
- }
|
|
||||||
- if (vector >= msix_nr_vectors_allocated(dev)) {
|
|
||||||
- return 0;
|
|
||||||
- }
|
|
||||||
- ret = kvm_virtio_pci_vq_vector_use(proxy, vector);
|
|
||||||
- if (ret < 0) {
|
|
||||||
- goto undo;
|
|
||||||
- }
|
|
||||||
- /*
|
|
||||||
- * If guest supports masking, set up irqfd now.
|
|
||||||
- * Otherwise, delay until unmasked in the frontend.
|
|
||||||
- */
|
|
||||||
- if (vdev->use_guest_notifier_mask && k->guest_notifier_mask) {
|
|
||||||
- ret = kvm_virtio_pci_irqfd_use(proxy, n, vector);
|
|
||||||
+ unsigned int vector;
|
|
||||||
+ int ret, queue_no;
|
|
||||||
+ EventNotifier *n;
|
|
||||||
+ for (queue_no = 0; queue_no < nvqs; queue_no++) {
|
|
||||||
+ if (!virtio_queue_get_num(vdev, queue_no)) {
|
|
||||||
+ break;
|
|
||||||
+ }
|
|
||||||
+ ret = virtio_pci_get_notifier(proxy, queue_no, &n, &vector);
|
|
||||||
+ if (ret < 0) {
|
|
||||||
+ break;
|
|
||||||
+ }
|
|
||||||
+ if (vector >= msix_nr_vectors_allocated(dev)) {
|
|
||||||
+ continue;
|
|
||||||
+ }
|
|
||||||
+ ret = kvm_virtio_pci_vq_vector_use(proxy, queue_no, vector);
|
|
||||||
if (ret < 0) {
|
|
||||||
- kvm_virtio_pci_vq_vector_release(proxy, vector);
|
|
||||||
goto undo;
|
|
||||||
}
|
|
||||||
+ /* If guest supports masking, set up irqfd now.
|
|
||||||
+ * Otherwise, delay until unmasked in the frontend.
|
|
||||||
+ */
|
|
||||||
+ if (vdev->use_guest_notifier_mask && k->guest_notifier_mask) {
|
|
||||||
+ ret = kvm_virtio_pci_irqfd_use(proxy, n, vector);
|
|
||||||
+ if (ret < 0) {
|
|
||||||
+ kvm_virtio_pci_vq_vector_release(proxy, vector);
|
|
||||||
+ goto undo;
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
}
|
|
||||||
-
|
|
||||||
return 0;
|
|
||||||
-undo:
|
|
||||||
|
|
||||||
- vector = virtio_queue_vector(vdev, queue_no);
|
|
||||||
- if (vector >= msix_nr_vectors_allocated(dev)) {
|
|
||||||
- return ret;
|
|
||||||
- }
|
|
||||||
- if (vdev->use_guest_notifier_mask && k->guest_notifier_mask) {
|
|
||||||
- ret = virtio_pci_get_notifier(proxy, queue_no, &n, &vector);
|
|
||||||
- if (ret < 0) {
|
|
||||||
- return ret;
|
|
||||||
+undo:
|
|
||||||
+ while (--queue_no >= 0) {
|
|
||||||
+ vector = virtio_queue_vector(vdev, queue_no);
|
|
||||||
+ if (vector >= msix_nr_vectors_allocated(dev)) {
|
|
||||||
+ continue;
|
|
||||||
}
|
|
||||||
- kvm_virtio_pci_irqfd_release(proxy, n, vector);
|
|
||||||
- }
|
|
||||||
- return ret;
|
|
||||||
-}
|
|
||||||
-static int kvm_virtio_pci_vector_use(VirtIOPCIProxy *proxy, int nvqs)
|
|
||||||
-{
|
|
||||||
- int queue_no;
|
|
||||||
- int ret = 0;
|
|
||||||
- VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);
|
|
||||||
-
|
|
||||||
- for (queue_no = 0; queue_no < nvqs; queue_no++) {
|
|
||||||
- if (!virtio_queue_get_num(vdev, queue_no)) {
|
|
||||||
- return -1;
|
|
||||||
+ if (vdev->use_guest_notifier_mask && k->guest_notifier_mask) {
|
|
||||||
+ ret = virtio_pci_get_notifier(proxy, queue_no, &n, &vector);
|
|
||||||
+ if (ret < 0) {
|
|
||||||
+ break;
|
|
||||||
+ }
|
|
||||||
+ kvm_virtio_pci_irqfd_release(proxy, n, vector);
|
|
||||||
}
|
|
||||||
- ret = kvm_virtio_pci_vector_use_one(proxy, queue_no);
|
|
||||||
+ kvm_virtio_pci_vq_vector_release(proxy, vector);
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
-
|
|
||||||
-static void kvm_virtio_pci_vector_release_one(VirtIOPCIProxy *proxy,
|
|
||||||
- int queue_no)
|
|
||||||
+static void kvm_virtio_pci_vector_release(VirtIOPCIProxy *proxy, int nvqs)
|
|
||||||
{
|
|
||||||
+ PCIDevice *dev = &proxy->pci_dev;
|
|
||||||
VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);
|
|
||||||
unsigned int vector;
|
|
||||||
- EventNotifier *n;
|
|
||||||
- int ret;
|
|
||||||
- VirtioDeviceClass *k = VIRTIO_DEVICE_GET_CLASS(vdev);
|
|
||||||
- PCIDevice *dev = &proxy->pci_dev;
|
|
||||||
-
|
|
||||||
- ret = virtio_pci_get_notifier(proxy, queue_no, &n, &vector);
|
|
||||||
- if (ret < 0) {
|
|
||||||
- return;
|
|
||||||
- }
|
|
||||||
- if (vector >= msix_nr_vectors_allocated(dev)) {
|
|
||||||
- return;
|
|
||||||
- }
|
|
||||||
- if (vdev->use_guest_notifier_mask && k->guest_notifier_mask) {
|
|
||||||
- kvm_virtio_pci_irqfd_release(proxy, n, vector);
|
|
||||||
- }
|
|
||||||
- kvm_virtio_pci_vq_vector_release(proxy, vector);
|
|
||||||
-}
|
|
||||||
-
|
|
||||||
-static void kvm_virtio_pci_vector_release(VirtIOPCIProxy *proxy, int nvqs)
|
|
||||||
-{
|
|
||||||
int queue_no;
|
|
||||||
- VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);
|
|
||||||
-
|
|
||||||
+ VirtioDeviceClass *k = VIRTIO_DEVICE_GET_CLASS(vdev);
|
|
||||||
+ EventNotifier *n;
|
|
||||||
+ int ret ;
|
|
||||||
for (queue_no = 0; queue_no < nvqs; queue_no++) {
|
|
||||||
if (!virtio_queue_get_num(vdev, queue_no)) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
- kvm_virtio_pci_vector_release_one(proxy, queue_no);
|
|
||||||
+ ret = virtio_pci_get_notifier(proxy, queue_no, &n, &vector);
|
|
||||||
+ if (ret < 0) {
|
|
||||||
+ break;
|
|
||||||
+ }
|
|
||||||
+ if (vector >= msix_nr_vectors_allocated(dev)) {
|
|
||||||
+ continue;
|
|
||||||
+ }
|
|
||||||
+ /* If guest supports masking, clean up irqfd now.
|
|
||||||
+ * Otherwise, it was cleaned when masked in the frontend.
|
|
||||||
+ */
|
|
||||||
+ if (vdev->use_guest_notifier_mask && k->guest_notifier_mask) {
|
|
||||||
+ kvm_virtio_pci_irqfd_release(proxy, n, vector);
|
|
||||||
+ }
|
|
||||||
+ kvm_virtio_pci_vq_vector_release(proxy, vector);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
--
|
|
||||||
2.27.0
|
|
||||||
|
|
||||||
@ -1,615 +0,0 @@
|
|||||||
From 4fe9da6fdaa5a9a12fdb26bf2a8c5abfccabf9e9 Mon Sep 17 00:00:00 2001
|
|
||||||
From: ling xu <ling1.xu@intel.com>
|
|
||||||
Date: Wed, 16 Nov 2022 23:29:23 +0800
|
|
||||||
Subject: [PATCH] Update bench-code for addressing CI problem
|
|
||||||
|
|
||||||
mainline inclusion
|
|
||||||
from mainline-v8.0.0-rc0
|
|
||||||
commit cc98c9fd5c17b8ab62ad91b183060d8f70b9d00d
|
|
||||||
category: feature
|
|
||||||
feature: AVX512 support for xbzrle_encode_buffer
|
|
||||||
bugzilla: https://gitee.com/openeuler/intel-qemu/issues/I6Z50P
|
|
||||||
|
|
||||||
Intel-SIG: commit cc98c9fd5c17 ("Update bench-code for addressing CI problem")
|
|
||||||
|
|
||||||
-------------------------------------
|
|
||||||
|
|
||||||
Update bench-code for addressing CI problem
|
|
||||||
|
|
||||||
Unit test code is in test-xbzrle.c, and benchmark code is in xbzrle-bench.c
|
|
||||||
for performance benchmarking. we have modified xbzrle-bench.c to address
|
|
||||||
CI problem.
|
|
||||||
|
|
||||||
Signed-off-by: ling xu <ling1.xu@intel.com>
|
|
||||||
Co-authored-by: Zhou Zhao <zhou.zhao@intel.com>
|
|
||||||
Co-authored-by: Jun Jin <jun.i.jin@intel.com>
|
|
||||||
Reviewed-by: Juan Quintela <quintela@redhat.com>
|
|
||||||
Signed-off-by: Juan Quintela <quintela@redhat.com>
|
|
||||||
Signed-off-by: Aichun Shi <aichun.shi@intel.com>
|
|
||||||
---
|
|
||||||
tests/bench/meson.build | 6 +
|
|
||||||
tests/bench/xbzrle-bench.c | 469 +++++++++++++++++++++++++++++++++++++
|
|
||||||
tests/unit/test-xbzrle.c | 39 ++-
|
|
||||||
3 files changed, 509 insertions(+), 5 deletions(-)
|
|
||||||
create mode 100644 tests/bench/xbzrle-bench.c
|
|
||||||
|
|
||||||
diff --git a/tests/bench/meson.build b/tests/bench/meson.build
|
|
||||||
index 00b3c209dc..54bc8938a8 100644
|
|
||||||
--- a/tests/bench/meson.build
|
|
||||||
+++ b/tests/bench/meson.build
|
|
||||||
@@ -3,6 +3,12 @@ qht_bench = executable('qht-bench',
|
|
||||||
sources: 'qht-bench.c',
|
|
||||||
dependencies: [qemuutil])
|
|
||||||
|
|
||||||
+if have_system
|
|
||||||
+xbzrle_bench = executable('xbzrle-bench',
|
|
||||||
+ sources: 'xbzrle-bench.c',
|
|
||||||
+ dependencies: [qemuutil,migration])
|
|
||||||
+endif
|
|
||||||
+
|
|
||||||
executable('atomic_add-bench',
|
|
||||||
sources: files('atomic_add-bench.c'),
|
|
||||||
dependencies: [qemuutil],
|
|
||||||
diff --git a/tests/bench/xbzrle-bench.c b/tests/bench/xbzrle-bench.c
|
|
||||||
new file mode 100644
|
|
||||||
index 0000000000..8848a3a32d
|
|
||||||
--- /dev/null
|
|
||||||
+++ b/tests/bench/xbzrle-bench.c
|
|
||||||
@@ -0,0 +1,469 @@
|
|
||||||
+/*
|
|
||||||
+ * Xor Based Zero Run Length Encoding unit tests.
|
|
||||||
+ *
|
|
||||||
+ * Copyright 2013 Red Hat, Inc. and/or its affiliates
|
|
||||||
+ *
|
|
||||||
+ * Authors:
|
|
||||||
+ * Orit Wasserman <owasserm@redhat.com>
|
|
||||||
+ *
|
|
||||||
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
|
|
||||||
+ * See the COPYING file in the top-level directory.
|
|
||||||
+ *
|
|
||||||
+ */
|
|
||||||
+#include "qemu/osdep.h"
|
|
||||||
+#include "qemu/cutils.h"
|
|
||||||
+#include "../migration/xbzrle.h"
|
|
||||||
+
|
|
||||||
+#if defined(CONFIG_AVX512BW_OPT)
|
|
||||||
+#define XBZRLE_PAGE_SIZE 4096
|
|
||||||
+static bool is_cpu_support_avx512bw;
|
|
||||||
+#include "qemu/cpuid.h"
|
|
||||||
+static void __attribute__((constructor)) init_cpu_flag(void)
|
|
||||||
+{
|
|
||||||
+ unsigned max = __get_cpuid_max(0, NULL);
|
|
||||||
+ int a, b, c, d;
|
|
||||||
+ is_cpu_support_avx512bw = false;
|
|
||||||
+ if (max >= 1) {
|
|
||||||
+ __cpuid(1, a, b, c, d);
|
|
||||||
+ /* We must check that AVX is not just available, but usable. */
|
|
||||||
+ if ((c & bit_OSXSAVE) && (c & bit_AVX) && max >= 7) {
|
|
||||||
+ int bv;
|
|
||||||
+ __asm("xgetbv" : "=a"(bv), "=d"(d) : "c"(0));
|
|
||||||
+ __cpuid_count(7, 0, a, b, c, d);
|
|
||||||
+ /* 0xe6:
|
|
||||||
+ * XCR0[7:5] = 111b (OPMASK state, upper 256-bit of ZMM0-ZMM15
|
|
||||||
+ * and ZMM16-ZMM31 state are enabled by OS)
|
|
||||||
+ * XCR0[2:1] = 11b (XMM state and YMM state are enabled by OS)
|
|
||||||
+ */
|
|
||||||
+ if ((bv & 0xe6) == 0xe6 && (b & bit_AVX512BW)) {
|
|
||||||
+ is_cpu_support_avx512bw = true;
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+ return ;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+struct ResTime {
|
|
||||||
+ float t_raw;
|
|
||||||
+ float t_512;
|
|
||||||
+};
|
|
||||||
+
|
|
||||||
+
|
|
||||||
+/* Function prototypes
|
|
||||||
+int xbzrle_encode_buffer_avx512(uint8_t *old_buf, uint8_t *new_buf, int slen,
|
|
||||||
+ uint8_t *dst, int dlen);
|
|
||||||
+*/
|
|
||||||
+static void encode_decode_zero(struct ResTime *res)
|
|
||||||
+{
|
|
||||||
+ uint8_t *buffer = g_malloc0(XBZRLE_PAGE_SIZE);
|
|
||||||
+ uint8_t *compressed = g_malloc0(XBZRLE_PAGE_SIZE);
|
|
||||||
+ uint8_t *buffer512 = g_malloc0(XBZRLE_PAGE_SIZE);
|
|
||||||
+ uint8_t *compressed512 = g_malloc0(XBZRLE_PAGE_SIZE);
|
|
||||||
+ int i = 0;
|
|
||||||
+ int dlen = 0, dlen512 = 0;
|
|
||||||
+ int diff_len = g_test_rand_int_range(0, XBZRLE_PAGE_SIZE - 1006);
|
|
||||||
+
|
|
||||||
+ for (i = diff_len; i > 0; i--) {
|
|
||||||
+ buffer[1000 + i] = i;
|
|
||||||
+ buffer512[1000 + i] = i;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ buffer[1000 + diff_len + 3] = 103;
|
|
||||||
+ buffer[1000 + diff_len + 5] = 105;
|
|
||||||
+
|
|
||||||
+ buffer512[1000 + diff_len + 3] = 103;
|
|
||||||
+ buffer512[1000 + diff_len + 5] = 105;
|
|
||||||
+
|
|
||||||
+ /* encode zero page */
|
|
||||||
+ time_t t_start, t_end, t_start512, t_end512;
|
|
||||||
+ t_start = clock();
|
|
||||||
+ dlen = xbzrle_encode_buffer(buffer, buffer, XBZRLE_PAGE_SIZE, compressed,
|
|
||||||
+ XBZRLE_PAGE_SIZE);
|
|
||||||
+ t_end = clock();
|
|
||||||
+ float time_val = difftime(t_end, t_start);
|
|
||||||
+ g_assert(dlen == 0);
|
|
||||||
+
|
|
||||||
+ t_start512 = clock();
|
|
||||||
+ dlen512 = xbzrle_encode_buffer_avx512(buffer512, buffer512, XBZRLE_PAGE_SIZE,
|
|
||||||
+ compressed512, XBZRLE_PAGE_SIZE);
|
|
||||||
+ t_end512 = clock();
|
|
||||||
+ float time_val512 = difftime(t_end512, t_start512);
|
|
||||||
+ g_assert(dlen512 == 0);
|
|
||||||
+
|
|
||||||
+ res->t_raw = time_val;
|
|
||||||
+ res->t_512 = time_val512;
|
|
||||||
+
|
|
||||||
+ g_free(buffer);
|
|
||||||
+ g_free(compressed);
|
|
||||||
+ g_free(buffer512);
|
|
||||||
+ g_free(compressed512);
|
|
||||||
+
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+static void test_encode_decode_zero_avx512(void)
|
|
||||||
+{
|
|
||||||
+ int i;
|
|
||||||
+ float time_raw = 0.0, time_512 = 0.0;
|
|
||||||
+ struct ResTime res;
|
|
||||||
+ for (i = 0; i < 10000; i++) {
|
|
||||||
+ encode_decode_zero(&res);
|
|
||||||
+ time_raw += res.t_raw;
|
|
||||||
+ time_512 += res.t_512;
|
|
||||||
+ }
|
|
||||||
+ printf("Zero test:\n");
|
|
||||||
+ printf("Raw xbzrle_encode time is %f ms\n", time_raw);
|
|
||||||
+ printf("512 xbzrle_encode time is %f ms\n", time_512);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+static void encode_decode_unchanged(struct ResTime *res)
|
|
||||||
+{
|
|
||||||
+ uint8_t *compressed = g_malloc0(XBZRLE_PAGE_SIZE);
|
|
||||||
+ uint8_t *test = g_malloc0(XBZRLE_PAGE_SIZE);
|
|
||||||
+ uint8_t *compressed512 = g_malloc0(XBZRLE_PAGE_SIZE);
|
|
||||||
+ uint8_t *test512 = g_malloc0(XBZRLE_PAGE_SIZE);
|
|
||||||
+ int i = 0;
|
|
||||||
+ int dlen = 0, dlen512 = 0;
|
|
||||||
+ int diff_len = g_test_rand_int_range(0, XBZRLE_PAGE_SIZE - 1006);
|
|
||||||
+
|
|
||||||
+ for (i = diff_len; i > 0; i--) {
|
|
||||||
+ test[1000 + i] = i + 4;
|
|
||||||
+ test512[1000 + i] = i + 4;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ test[1000 + diff_len + 3] = 107;
|
|
||||||
+ test[1000 + diff_len + 5] = 109;
|
|
||||||
+
|
|
||||||
+ test512[1000 + diff_len + 3] = 107;
|
|
||||||
+ test512[1000 + diff_len + 5] = 109;
|
|
||||||
+
|
|
||||||
+ /* test unchanged buffer */
|
|
||||||
+ time_t t_start, t_end, t_start512, t_end512;
|
|
||||||
+ t_start = clock();
|
|
||||||
+ dlen = xbzrle_encode_buffer(test, test, XBZRLE_PAGE_SIZE, compressed,
|
|
||||||
+ XBZRLE_PAGE_SIZE);
|
|
||||||
+ t_end = clock();
|
|
||||||
+ float time_val = difftime(t_end, t_start);
|
|
||||||
+ g_assert(dlen == 0);
|
|
||||||
+
|
|
||||||
+ t_start512 = clock();
|
|
||||||
+ dlen512 = xbzrle_encode_buffer_avx512(test512, test512, XBZRLE_PAGE_SIZE,
|
|
||||||
+ compressed512, XBZRLE_PAGE_SIZE);
|
|
||||||
+ t_end512 = clock();
|
|
||||||
+ float time_val512 = difftime(t_end512, t_start512);
|
|
||||||
+ g_assert(dlen512 == 0);
|
|
||||||
+
|
|
||||||
+ res->t_raw = time_val;
|
|
||||||
+ res->t_512 = time_val512;
|
|
||||||
+
|
|
||||||
+ g_free(test);
|
|
||||||
+ g_free(compressed);
|
|
||||||
+ g_free(test512);
|
|
||||||
+ g_free(compressed512);
|
|
||||||
+
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+static void test_encode_decode_unchanged_avx512(void)
|
|
||||||
+{
|
|
||||||
+ int i;
|
|
||||||
+ float time_raw = 0.0, time_512 = 0.0;
|
|
||||||
+ struct ResTime res;
|
|
||||||
+ for (i = 0; i < 10000; i++) {
|
|
||||||
+ encode_decode_unchanged(&res);
|
|
||||||
+ time_raw += res.t_raw;
|
|
||||||
+ time_512 += res.t_512;
|
|
||||||
+ }
|
|
||||||
+ printf("Unchanged test:\n");
|
|
||||||
+ printf("Raw xbzrle_encode time is %f ms\n", time_raw);
|
|
||||||
+ printf("512 xbzrle_encode time is %f ms\n", time_512);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+static void encode_decode_1_byte(struct ResTime *res)
|
|
||||||
+{
|
|
||||||
+ uint8_t *buffer = g_malloc0(XBZRLE_PAGE_SIZE);
|
|
||||||
+ uint8_t *test = g_malloc0(XBZRLE_PAGE_SIZE);
|
|
||||||
+ uint8_t *compressed = g_malloc(XBZRLE_PAGE_SIZE);
|
|
||||||
+ uint8_t *buffer512 = g_malloc0(XBZRLE_PAGE_SIZE);
|
|
||||||
+ uint8_t *test512 = g_malloc0(XBZRLE_PAGE_SIZE);
|
|
||||||
+ uint8_t *compressed512 = g_malloc(XBZRLE_PAGE_SIZE);
|
|
||||||
+ int dlen = 0, rc = 0, dlen512 = 0, rc512 = 0;
|
|
||||||
+ uint8_t buf[2];
|
|
||||||
+ uint8_t buf512[2];
|
|
||||||
+
|
|
||||||
+ test[XBZRLE_PAGE_SIZE - 1] = 1;
|
|
||||||
+ test512[XBZRLE_PAGE_SIZE - 1] = 1;
|
|
||||||
+
|
|
||||||
+ time_t t_start, t_end, t_start512, t_end512;
|
|
||||||
+ t_start = clock();
|
|
||||||
+ dlen = xbzrle_encode_buffer(buffer, test, XBZRLE_PAGE_SIZE, compressed,
|
|
||||||
+ XBZRLE_PAGE_SIZE);
|
|
||||||
+ t_end = clock();
|
|
||||||
+ float time_val = difftime(t_end, t_start);
|
|
||||||
+ g_assert(dlen == (uleb128_encode_small(&buf[0], 4095) + 2));
|
|
||||||
+
|
|
||||||
+ rc = xbzrle_decode_buffer(compressed, dlen, buffer, XBZRLE_PAGE_SIZE);
|
|
||||||
+ g_assert(rc == XBZRLE_PAGE_SIZE);
|
|
||||||
+ g_assert(memcmp(test, buffer, XBZRLE_PAGE_SIZE) == 0);
|
|
||||||
+
|
|
||||||
+ t_start512 = clock();
|
|
||||||
+ dlen512 = xbzrle_encode_buffer_avx512(buffer512, test512, XBZRLE_PAGE_SIZE,
|
|
||||||
+ compressed512, XBZRLE_PAGE_SIZE);
|
|
||||||
+ t_end512 = clock();
|
|
||||||
+ float time_val512 = difftime(t_end512, t_start512);
|
|
||||||
+ g_assert(dlen512 == (uleb128_encode_small(&buf512[0], 4095) + 2));
|
|
||||||
+
|
|
||||||
+ rc512 = xbzrle_decode_buffer(compressed512, dlen512, buffer512,
|
|
||||||
+ XBZRLE_PAGE_SIZE);
|
|
||||||
+ g_assert(rc512 == XBZRLE_PAGE_SIZE);
|
|
||||||
+ g_assert(memcmp(test512, buffer512, XBZRLE_PAGE_SIZE) == 0);
|
|
||||||
+
|
|
||||||
+ res->t_raw = time_val;
|
|
||||||
+ res->t_512 = time_val512;
|
|
||||||
+
|
|
||||||
+ g_free(buffer);
|
|
||||||
+ g_free(compressed);
|
|
||||||
+ g_free(test);
|
|
||||||
+ g_free(buffer512);
|
|
||||||
+ g_free(compressed512);
|
|
||||||
+ g_free(test512);
|
|
||||||
+
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+static void test_encode_decode_1_byte_avx512(void)
|
|
||||||
+{
|
|
||||||
+ int i;
|
|
||||||
+ float time_raw = 0.0, time_512 = 0.0;
|
|
||||||
+ struct ResTime res;
|
|
||||||
+ for (i = 0; i < 10000; i++) {
|
|
||||||
+ encode_decode_1_byte(&res);
|
|
||||||
+ time_raw += res.t_raw;
|
|
||||||
+ time_512 += res.t_512;
|
|
||||||
+ }
|
|
||||||
+ printf("1 byte test:\n");
|
|
||||||
+ printf("Raw xbzrle_encode time is %f ms\n", time_raw);
|
|
||||||
+ printf("512 xbzrle_encode time is %f ms\n", time_512);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+static void encode_decode_overflow(struct ResTime *res)
|
|
||||||
+{
|
|
||||||
+ uint8_t *compressed = g_malloc0(XBZRLE_PAGE_SIZE);
|
|
||||||
+ uint8_t *test = g_malloc0(XBZRLE_PAGE_SIZE);
|
|
||||||
+ uint8_t *buffer = g_malloc0(XBZRLE_PAGE_SIZE);
|
|
||||||
+ uint8_t *compressed512 = g_malloc0(XBZRLE_PAGE_SIZE);
|
|
||||||
+ uint8_t *test512 = g_malloc0(XBZRLE_PAGE_SIZE);
|
|
||||||
+ uint8_t *buffer512 = g_malloc0(XBZRLE_PAGE_SIZE);
|
|
||||||
+ int i = 0, rc = 0, rc512 = 0;
|
|
||||||
+
|
|
||||||
+ for (i = 0; i < XBZRLE_PAGE_SIZE / 2 - 1; i++) {
|
|
||||||
+ test[i * 2] = 1;
|
|
||||||
+ test512[i * 2] = 1;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ /* encode overflow */
|
|
||||||
+ time_t t_start, t_end, t_start512, t_end512;
|
|
||||||
+ t_start = clock();
|
|
||||||
+ rc = xbzrle_encode_buffer(buffer, test, XBZRLE_PAGE_SIZE, compressed,
|
|
||||||
+ XBZRLE_PAGE_SIZE);
|
|
||||||
+ t_end = clock();
|
|
||||||
+ float time_val = difftime(t_end, t_start);
|
|
||||||
+ g_assert(rc == -1);
|
|
||||||
+
|
|
||||||
+ t_start512 = clock();
|
|
||||||
+ rc512 = xbzrle_encode_buffer_avx512(buffer512, test512, XBZRLE_PAGE_SIZE,
|
|
||||||
+ compressed512, XBZRLE_PAGE_SIZE);
|
|
||||||
+ t_end512 = clock();
|
|
||||||
+ float time_val512 = difftime(t_end512, t_start512);
|
|
||||||
+ g_assert(rc512 == -1);
|
|
||||||
+
|
|
||||||
+ res->t_raw = time_val;
|
|
||||||
+ res->t_512 = time_val512;
|
|
||||||
+
|
|
||||||
+ g_free(buffer);
|
|
||||||
+ g_free(compressed);
|
|
||||||
+ g_free(test);
|
|
||||||
+ g_free(buffer512);
|
|
||||||
+ g_free(compressed512);
|
|
||||||
+ g_free(test512);
|
|
||||||
+
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+static void test_encode_decode_overflow_avx512(void)
|
|
||||||
+{
|
|
||||||
+ int i;
|
|
||||||
+ float time_raw = 0.0, time_512 = 0.0;
|
|
||||||
+ struct ResTime res;
|
|
||||||
+ for (i = 0; i < 10000; i++) {
|
|
||||||
+ encode_decode_overflow(&res);
|
|
||||||
+ time_raw += res.t_raw;
|
|
||||||
+ time_512 += res.t_512;
|
|
||||||
+ }
|
|
||||||
+ printf("Overflow test:\n");
|
|
||||||
+ printf("Raw xbzrle_encode time is %f ms\n", time_raw);
|
|
||||||
+ printf("512 xbzrle_encode time is %f ms\n", time_512);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+static void encode_decode_range_avx512(struct ResTime *res)
|
|
||||||
+{
|
|
||||||
+ uint8_t *buffer = g_malloc0(XBZRLE_PAGE_SIZE);
|
|
||||||
+ uint8_t *compressed = g_malloc(XBZRLE_PAGE_SIZE);
|
|
||||||
+ uint8_t *test = g_malloc0(XBZRLE_PAGE_SIZE);
|
|
||||||
+ uint8_t *buffer512 = g_malloc0(XBZRLE_PAGE_SIZE);
|
|
||||||
+ uint8_t *compressed512 = g_malloc(XBZRLE_PAGE_SIZE);
|
|
||||||
+ uint8_t *test512 = g_malloc0(XBZRLE_PAGE_SIZE);
|
|
||||||
+ int i = 0, rc = 0, rc512 = 0;
|
|
||||||
+ int dlen = 0, dlen512 = 0;
|
|
||||||
+
|
|
||||||
+ int diff_len = g_test_rand_int_range(0, XBZRLE_PAGE_SIZE - 1006);
|
|
||||||
+
|
|
||||||
+ for (i = diff_len; i > 0; i--) {
|
|
||||||
+ buffer[1000 + i] = i;
|
|
||||||
+ test[1000 + i] = i + 4;
|
|
||||||
+ buffer512[1000 + i] = i;
|
|
||||||
+ test512[1000 + i] = i + 4;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ buffer[1000 + diff_len + 3] = 103;
|
|
||||||
+ test[1000 + diff_len + 3] = 107;
|
|
||||||
+
|
|
||||||
+ buffer[1000 + diff_len + 5] = 105;
|
|
||||||
+ test[1000 + diff_len + 5] = 109;
|
|
||||||
+
|
|
||||||
+ buffer512[1000 + diff_len + 3] = 103;
|
|
||||||
+ test512[1000 + diff_len + 3] = 107;
|
|
||||||
+
|
|
||||||
+ buffer512[1000 + diff_len + 5] = 105;
|
|
||||||
+ test512[1000 + diff_len + 5] = 109;
|
|
||||||
+
|
|
||||||
+ /* test encode/decode */
|
|
||||||
+ time_t t_start, t_end, t_start512, t_end512;
|
|
||||||
+ t_start = clock();
|
|
||||||
+ dlen = xbzrle_encode_buffer(test, buffer, XBZRLE_PAGE_SIZE, compressed,
|
|
||||||
+ XBZRLE_PAGE_SIZE);
|
|
||||||
+ t_end = clock();
|
|
||||||
+ float time_val = difftime(t_end, t_start);
|
|
||||||
+ rc = xbzrle_decode_buffer(compressed, dlen, test, XBZRLE_PAGE_SIZE);
|
|
||||||
+ g_assert(rc < XBZRLE_PAGE_SIZE);
|
|
||||||
+ g_assert(memcmp(test, buffer, XBZRLE_PAGE_SIZE) == 0);
|
|
||||||
+
|
|
||||||
+ t_start512 = clock();
|
|
||||||
+ dlen512 = xbzrle_encode_buffer_avx512(test512, buffer512, XBZRLE_PAGE_SIZE,
|
|
||||||
+ compressed512, XBZRLE_PAGE_SIZE);
|
|
||||||
+ t_end512 = clock();
|
|
||||||
+ float time_val512 = difftime(t_end512, t_start512);
|
|
||||||
+ rc512 = xbzrle_decode_buffer(compressed512, dlen512, test512, XBZRLE_PAGE_SIZE);
|
|
||||||
+ g_assert(rc512 < XBZRLE_PAGE_SIZE);
|
|
||||||
+ g_assert(memcmp(test512, buffer512, XBZRLE_PAGE_SIZE) == 0);
|
|
||||||
+
|
|
||||||
+ res->t_raw = time_val;
|
|
||||||
+ res->t_512 = time_val512;
|
|
||||||
+
|
|
||||||
+ g_free(buffer);
|
|
||||||
+ g_free(compressed);
|
|
||||||
+ g_free(test);
|
|
||||||
+ g_free(buffer512);
|
|
||||||
+ g_free(compressed512);
|
|
||||||
+ g_free(test512);
|
|
||||||
+
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+static void test_encode_decode_avx512(void)
|
|
||||||
+{
|
|
||||||
+ int i;
|
|
||||||
+ float time_raw = 0.0, time_512 = 0.0;
|
|
||||||
+ struct ResTime res;
|
|
||||||
+ for (i = 0; i < 10000; i++) {
|
|
||||||
+ encode_decode_range_avx512(&res);
|
|
||||||
+ time_raw += res.t_raw;
|
|
||||||
+ time_512 += res.t_512;
|
|
||||||
+ }
|
|
||||||
+ printf("Encode decode test:\n");
|
|
||||||
+ printf("Raw xbzrle_encode time is %f ms\n", time_raw);
|
|
||||||
+ printf("512 xbzrle_encode time is %f ms\n", time_512);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+static void encode_decode_random(struct ResTime *res)
|
|
||||||
+{
|
|
||||||
+ uint8_t *buffer = g_malloc0(XBZRLE_PAGE_SIZE);
|
|
||||||
+ uint8_t *compressed = g_malloc(XBZRLE_PAGE_SIZE);
|
|
||||||
+ uint8_t *test = g_malloc0(XBZRLE_PAGE_SIZE);
|
|
||||||
+ uint8_t *buffer512 = g_malloc0(XBZRLE_PAGE_SIZE);
|
|
||||||
+ uint8_t *compressed512 = g_malloc(XBZRLE_PAGE_SIZE);
|
|
||||||
+ uint8_t *test512 = g_malloc0(XBZRLE_PAGE_SIZE);
|
|
||||||
+ int i = 0, rc = 0, rc512 = 0;
|
|
||||||
+ int dlen = 0, dlen512 = 0;
|
|
||||||
+
|
|
||||||
+ int diff_len = g_test_rand_int_range(0, XBZRLE_PAGE_SIZE - 1);
|
|
||||||
+ /* store the index of diff */
|
|
||||||
+ int dirty_index[diff_len];
|
|
||||||
+ for (int j = 0; j < diff_len; j++) {
|
|
||||||
+ dirty_index[j] = g_test_rand_int_range(0, XBZRLE_PAGE_SIZE - 1);
|
|
||||||
+ }
|
|
||||||
+ for (i = diff_len - 1; i >= 0; i--) {
|
|
||||||
+ buffer[dirty_index[i]] = i;
|
|
||||||
+ test[dirty_index[i]] = i + 4;
|
|
||||||
+ buffer512[dirty_index[i]] = i;
|
|
||||||
+ test512[dirty_index[i]] = i + 4;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ time_t t_start, t_end, t_start512, t_end512;
|
|
||||||
+ t_start = clock();
|
|
||||||
+ dlen = xbzrle_encode_buffer(test, buffer, XBZRLE_PAGE_SIZE, compressed,
|
|
||||||
+ XBZRLE_PAGE_SIZE);
|
|
||||||
+ t_end = clock();
|
|
||||||
+ float time_val = difftime(t_end, t_start);
|
|
||||||
+ rc = xbzrle_decode_buffer(compressed, dlen, test, XBZRLE_PAGE_SIZE);
|
|
||||||
+ g_assert(rc < XBZRLE_PAGE_SIZE);
|
|
||||||
+
|
|
||||||
+ t_start512 = clock();
|
|
||||||
+ dlen512 = xbzrle_encode_buffer_avx512(test512, buffer512, XBZRLE_PAGE_SIZE,
|
|
||||||
+ compressed512, XBZRLE_PAGE_SIZE);
|
|
||||||
+ t_end512 = clock();
|
|
||||||
+ float time_val512 = difftime(t_end512, t_start512);
|
|
||||||
+ rc512 = xbzrle_decode_buffer(compressed512, dlen512, test512, XBZRLE_PAGE_SIZE);
|
|
||||||
+ g_assert(rc512 < XBZRLE_PAGE_SIZE);
|
|
||||||
+
|
|
||||||
+ res->t_raw = time_val;
|
|
||||||
+ res->t_512 = time_val512;
|
|
||||||
+
|
|
||||||
+ g_free(buffer);
|
|
||||||
+ g_free(compressed);
|
|
||||||
+ g_free(test);
|
|
||||||
+ g_free(buffer512);
|
|
||||||
+ g_free(compressed512);
|
|
||||||
+ g_free(test512);
|
|
||||||
+
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+static void test_encode_decode_random_avx512(void)
|
|
||||||
+{
|
|
||||||
+ int i;
|
|
||||||
+ float time_raw = 0.0, time_512 = 0.0;
|
|
||||||
+ struct ResTime res;
|
|
||||||
+ for (i = 0; i < 10000; i++) {
|
|
||||||
+ encode_decode_random(&res);
|
|
||||||
+ time_raw += res.t_raw;
|
|
||||||
+ time_512 += res.t_512;
|
|
||||||
+ }
|
|
||||||
+ printf("Random test:\n");
|
|
||||||
+ printf("Raw xbzrle_encode time is %f ms\n", time_raw);
|
|
||||||
+ printf("512 xbzrle_encode time is %f ms\n", time_512);
|
|
||||||
+}
|
|
||||||
+#endif
|
|
||||||
+
|
|
||||||
+int main(int argc, char **argv)
|
|
||||||
+{
|
|
||||||
+ g_test_init(&argc, &argv, NULL);
|
|
||||||
+ g_test_rand_int();
|
|
||||||
+ #if defined(CONFIG_AVX512BW_OPT)
|
|
||||||
+ if (likely(is_cpu_support_avx512bw)) {
|
|
||||||
+ g_test_add_func("/xbzrle/encode_decode_zero", test_encode_decode_zero_avx512);
|
|
||||||
+ g_test_add_func("/xbzrle/encode_decode_unchanged",
|
|
||||||
+ test_encode_decode_unchanged_avx512);
|
|
||||||
+ g_test_add_func("/xbzrle/encode_decode_1_byte", test_encode_decode_1_byte_avx512);
|
|
||||||
+ g_test_add_func("/xbzrle/encode_decode_overflow",
|
|
||||||
+ test_encode_decode_overflow_avx512);
|
|
||||||
+ g_test_add_func("/xbzrle/encode_decode", test_encode_decode_avx512);
|
|
||||||
+ g_test_add_func("/xbzrle/encode_decode_random", test_encode_decode_random_avx512);
|
|
||||||
+ }
|
|
||||||
+ #endif
|
|
||||||
+ return g_test_run();
|
|
||||||
+}
|
|
||||||
diff --git a/tests/unit/test-xbzrle.c b/tests/unit/test-xbzrle.c
|
|
||||||
index 795d6f1cba..baa364b443 100644
|
|
||||||
--- a/tests/unit/test-xbzrle.c
|
|
||||||
+++ b/tests/unit/test-xbzrle.c
|
|
||||||
@@ -17,6 +17,35 @@
|
|
||||||
|
|
||||||
#define XBZRLE_PAGE_SIZE 4096
|
|
||||||
|
|
||||||
+int (*xbzrle_encode_buffer_func)(uint8_t *, uint8_t *, int,
|
|
||||||
+ uint8_t *, int) = xbzrle_encode_buffer;
|
|
||||||
+#if defined(CONFIG_AVX512BW_OPT)
|
|
||||||
+#include "qemu/cpuid.h"
|
|
||||||
+static void __attribute__((constructor)) init_cpu_flag(void)
|
|
||||||
+{
|
|
||||||
+ unsigned max = __get_cpuid_max(0, NULL);
|
|
||||||
+ int a, b, c, d;
|
|
||||||
+ if (max >= 1) {
|
|
||||||
+ __cpuid(1, a, b, c, d);
|
|
||||||
+ /* We must check that AVX is not just available, but usable. */
|
|
||||||
+ if ((c & bit_OSXSAVE) && (c & bit_AVX) && max >= 7) {
|
|
||||||
+ int bv;
|
|
||||||
+ __asm("xgetbv" : "=a"(bv), "=d"(d) : "c"(0));
|
|
||||||
+ __cpuid_count(7, 0, a, b, c, d);
|
|
||||||
+ /* 0xe6:
|
|
||||||
+ * XCR0[7:5] = 111b (OPMASK state, upper 256-bit of ZMM0-ZMM15
|
|
||||||
+ * and ZMM16-ZMM31 state are enabled by OS)
|
|
||||||
+ * XCR0[2:1] = 11b (XMM state and YMM state are enabled by OS)
|
|
||||||
+ */
|
|
||||||
+ if ((bv & 0xe6) == 0xe6 && (b & bit_AVX512BW)) {
|
|
||||||
+ xbzrle_encode_buffer_func = xbzrle_encode_buffer_avx512;
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+ return ;
|
|
||||||
+}
|
|
||||||
+#endif
|
|
||||||
+
|
|
||||||
static void test_uleb(void)
|
|
||||||
{
|
|
||||||
uint32_t i, val;
|
|
||||||
@@ -55,7 +84,7 @@ static void test_encode_decode_zero(void)
|
|
||||||
buffer[1000 + diff_len + 5] = 105;
|
|
||||||
|
|
||||||
/* encode zero page */
|
|
||||||
- dlen = xbzrle_encode_buffer(buffer, buffer, XBZRLE_PAGE_SIZE, compressed,
|
|
||||||
+ dlen = xbzrle_encode_buffer_func(buffer, buffer, XBZRLE_PAGE_SIZE, compressed,
|
|
||||||
XBZRLE_PAGE_SIZE);
|
|
||||||
g_assert(dlen == 0);
|
|
||||||
|
|
||||||
@@ -79,7 +108,7 @@ static void test_encode_decode_unchanged(void)
|
|
||||||
test[1000 + diff_len + 5] = 109;
|
|
||||||
|
|
||||||
/* test unchanged buffer */
|
|
||||||
- dlen = xbzrle_encode_buffer(test, test, XBZRLE_PAGE_SIZE, compressed,
|
|
||||||
+ dlen = xbzrle_encode_buffer_func(test, test, XBZRLE_PAGE_SIZE, compressed,
|
|
||||||
XBZRLE_PAGE_SIZE);
|
|
||||||
g_assert(dlen == 0);
|
|
||||||
|
|
||||||
@@ -97,7 +126,7 @@ static void test_encode_decode_1_byte(void)
|
|
||||||
|
|
||||||
test[XBZRLE_PAGE_SIZE - 1] = 1;
|
|
||||||
|
|
||||||
- dlen = xbzrle_encode_buffer(buffer, test, XBZRLE_PAGE_SIZE, compressed,
|
|
||||||
+ dlen = xbzrle_encode_buffer_func(buffer, test, XBZRLE_PAGE_SIZE, compressed,
|
|
||||||
XBZRLE_PAGE_SIZE);
|
|
||||||
g_assert(dlen == (uleb128_encode_small(&buf[0], 4095) + 2));
|
|
||||||
|
|
||||||
@@ -122,7 +151,7 @@ static void test_encode_decode_overflow(void)
|
|
||||||
}
|
|
||||||
|
|
||||||
/* encode overflow */
|
|
||||||
- rc = xbzrle_encode_buffer(buffer, test, XBZRLE_PAGE_SIZE, compressed,
|
|
||||||
+ rc = xbzrle_encode_buffer_func(buffer, test, XBZRLE_PAGE_SIZE, compressed,
|
|
||||||
XBZRLE_PAGE_SIZE);
|
|
||||||
g_assert(rc == -1);
|
|
||||||
|
|
||||||
@@ -153,7 +182,7 @@ static void encode_decode_range(void)
|
|
||||||
test[1000 + diff_len + 5] = 109;
|
|
||||||
|
|
||||||
/* test encode/decode */
|
|
||||||
- dlen = xbzrle_encode_buffer(test, buffer, XBZRLE_PAGE_SIZE, compressed,
|
|
||||||
+ dlen = xbzrle_encode_buffer_func(test, buffer, XBZRLE_PAGE_SIZE, compressed,
|
|
||||||
XBZRLE_PAGE_SIZE);
|
|
||||||
|
|
||||||
rc = xbzrle_decode_buffer(compressed, dlen, test, XBZRLE_PAGE_SIZE);
|
|
||||||
--
|
|
||||||
2.27.0
|
|
||||||
|
|
||||||
@ -1,250 +0,0 @@
|
|||||||
From 97021cac0565f57d14a3e285399dd2208c66c358 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Yan Wang <wangyan122@huawei.com>
|
|
||||||
Date: Sat, 12 Feb 2022 15:00:25 +0800
|
|
||||||
Subject: [PATCH] Use post-increment only in inffast.c.
|
|
||||||
|
|
||||||
Fix CVE-2016-9841
|
|
||||||
|
|
||||||
patch link: https://github.com/madler/zlib/commit/9aaec95
|
|
||||||
|
|
||||||
An old inffast.c optimization turns out to not be optimal anymore
|
|
||||||
with modern compilers, and furthermore was not compliant with the
|
|
||||||
C standard, for which decrementing a pointer before its allocated
|
|
||||||
memory is undefined. Per the recommendation of a security audit of
|
|
||||||
the zlib code by Trail of Bits and TrustInSoft, in support of the
|
|
||||||
Mozilla Foundation, this "optimization" was removed, in order to
|
|
||||||
avoid the possibility of undefined behavior.
|
|
||||||
|
|
||||||
Signed-off-by: Yan Wang <wangyan122@huawei.com>
|
|
||||||
---
|
|
||||||
roms/u-boot/lib/zlib/inffast.c | 87 +++++++++++++++++-------------------------
|
|
||||||
1 file changed, 34 insertions(+), 53 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/roms/u-boot/lib/zlib/inffast.c b/roms/u-boot/lib/zlib/inffast.c
|
|
||||||
index e3c7f3b..cdc778e 100644
|
|
||||||
--- a/roms/u-boot/lib/zlib/inffast.c
|
|
||||||
+++ b/roms/u-boot/lib/zlib/inffast.c
|
|
||||||
@@ -12,25 +12,6 @@
|
|
||||||
|
|
||||||
#ifndef ASMINF
|
|
||||||
|
|
||||||
-/* Allow machine dependent optimization for post-increment or pre-increment.
|
|
||||||
- Based on testing to date,
|
|
||||||
- Pre-increment preferred for:
|
|
||||||
- - PowerPC G3 (Adler)
|
|
||||||
- - MIPS R5000 (Randers-Pehrson)
|
|
||||||
- Post-increment preferred for:
|
|
||||||
- - none
|
|
||||||
- No measurable difference:
|
|
||||||
- - Pentium III (Anderson)
|
|
||||||
- - M68060 (Nikl)
|
|
||||||
- */
|
|
||||||
-#ifdef POSTINC
|
|
||||||
-# define OFF 0
|
|
||||||
-# define PUP(a) *(a)++
|
|
||||||
-#else
|
|
||||||
-# define OFF 1
|
|
||||||
-# define PUP(a) *++(a)
|
|
||||||
-#endif
|
|
||||||
-
|
|
||||||
/*
|
|
||||||
Decode literal, length, and distance codes and write out the resulting
|
|
||||||
literal and match bytes until either not enough input or output is
|
|
||||||
@@ -97,7 +78,7 @@ void inflate_fast(z_streamp strm, unsigned start)
|
|
||||||
|
|
||||||
/* copy state to local variables */
|
|
||||||
state = (struct inflate_state FAR *)strm->state;
|
|
||||||
- in = strm->next_in - OFF;
|
|
||||||
+ in = strm->next_in;
|
|
||||||
last = in + (strm->avail_in - 5);
|
|
||||||
if (in > last && strm->avail_in > 5) {
|
|
||||||
/*
|
|
||||||
@@ -107,7 +88,7 @@ void inflate_fast(z_streamp strm, unsigned start)
|
|
||||||
strm->avail_in = 0xffffffff - (uintptr_t)in;
|
|
||||||
last = in + (strm->avail_in - 5);
|
|
||||||
}
|
|
||||||
- out = strm->next_out - OFF;
|
|
||||||
+ out = strm->next_out;
|
|
||||||
beg = out - (start - strm->avail_out);
|
|
||||||
end = out + (strm->avail_out - 257);
|
|
||||||
#ifdef INFLATE_STRICT
|
|
||||||
@@ -128,9 +109,9 @@ void inflate_fast(z_streamp strm, unsigned start)
|
|
||||||
input data or output space */
|
|
||||||
do {
|
|
||||||
if (bits < 15) {
|
|
||||||
- hold += (unsigned long)(PUP(in)) << bits;
|
|
||||||
+ hold += (unsigned long)(*in++) << bits;
|
|
||||||
bits += 8;
|
|
||||||
- hold += (unsigned long)(PUP(in)) << bits;
|
|
||||||
+ hold += (unsigned long)(*in++) << bits;
|
|
||||||
bits += 8;
|
|
||||||
}
|
|
||||||
this = lcode[hold & lmask];
|
|
||||||
@@ -143,14 +124,14 @@ void inflate_fast(z_streamp strm, unsigned start)
|
|
||||||
Tracevv((stderr, this.val >= 0x20 && this.val < 0x7f ?
|
|
||||||
"inflate: literal '%c'\n" :
|
|
||||||
"inflate: literal 0x%02x\n", this.val));
|
|
||||||
- PUP(out) = (unsigned char)(this.val);
|
|
||||||
+ *out++ = (unsigned char)(this.val);
|
|
||||||
}
|
|
||||||
else if (op & 16) { /* length base */
|
|
||||||
len = (unsigned)(this.val);
|
|
||||||
op &= 15; /* number of extra bits */
|
|
||||||
if (op) {
|
|
||||||
if (bits < op) {
|
|
||||||
- hold += (unsigned long)(PUP(in)) << bits;
|
|
||||||
+ hold += (unsigned long)(*in++) << bits;
|
|
||||||
bits += 8;
|
|
||||||
}
|
|
||||||
len += (unsigned)hold & ((1U << op) - 1);
|
|
||||||
@@ -159,9 +140,9 @@ void inflate_fast(z_streamp strm, unsigned start)
|
|
||||||
}
|
|
||||||
Tracevv((stderr, "inflate: length %u\n", len));
|
|
||||||
if (bits < 15) {
|
|
||||||
- hold += (unsigned long)(PUP(in)) << bits;
|
|
||||||
+ hold += (unsigned long)(*in++) << bits;
|
|
||||||
bits += 8;
|
|
||||||
- hold += (unsigned long)(PUP(in)) << bits;
|
|
||||||
+ hold += (unsigned long)(*in++) << bits;
|
|
||||||
bits += 8;
|
|
||||||
}
|
|
||||||
this = dcode[hold & dmask];
|
|
||||||
@@ -174,10 +155,10 @@ void inflate_fast(z_streamp strm, unsigned start)
|
|
||||||
dist = (unsigned)(this.val);
|
|
||||||
op &= 15; /* number of extra bits */
|
|
||||||
if (bits < op) {
|
|
||||||
- hold += (unsigned long)(PUP(in)) << bits;
|
|
||||||
+ hold += (unsigned long)(*in++) << bits;
|
|
||||||
bits += 8;
|
|
||||||
if (bits < op) {
|
|
||||||
- hold += (unsigned long)(PUP(in)) << bits;
|
|
||||||
+ hold += (unsigned long)(*in++) << bits;
|
|
||||||
bits += 8;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -200,13 +181,13 @@ void inflate_fast(z_streamp strm, unsigned start)
|
|
||||||
state->mode = BAD;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
- from = window - OFF;
|
|
||||||
+ from = window;
|
|
||||||
if (write == 0) { /* very common case */
|
|
||||||
from += wsize - op;
|
|
||||||
if (op < len) { /* some from window */
|
|
||||||
len -= op;
|
|
||||||
do {
|
|
||||||
- PUP(out) = PUP(from);
|
|
||||||
+ *out++ = *from++;
|
|
||||||
} while (--op);
|
|
||||||
from = out - dist; /* rest from output */
|
|
||||||
}
|
|
||||||
@@ -217,14 +198,14 @@ void inflate_fast(z_streamp strm, unsigned start)
|
|
||||||
if (op < len) { /* some from end of window */
|
|
||||||
len -= op;
|
|
||||||
do {
|
|
||||||
- PUP(out) = PUP(from);
|
|
||||||
+ *out++ = *from++;
|
|
||||||
} while (--op);
|
|
||||||
- from = window - OFF;
|
|
||||||
+ from = window;
|
|
||||||
if (write < len) { /* some from start of window */
|
|
||||||
op = write;
|
|
||||||
len -= op;
|
|
||||||
do {
|
|
||||||
- PUP(out) = PUP(from);
|
|
||||||
+ *out++ = *from++;
|
|
||||||
} while (--op);
|
|
||||||
from = out - dist; /* rest from output */
|
|
||||||
}
|
|
||||||
@@ -235,21 +216,21 @@ void inflate_fast(z_streamp strm, unsigned start)
|
|
||||||
if (op < len) { /* some from window */
|
|
||||||
len -= op;
|
|
||||||
do {
|
|
||||||
- PUP(out) = PUP(from);
|
|
||||||
+ *out++ = *from++;
|
|
||||||
} while (--op);
|
|
||||||
from = out - dist; /* rest from output */
|
|
||||||
}
|
|
||||||
}
|
|
||||||
while (len > 2) {
|
|
||||||
- PUP(out) = PUP(from);
|
|
||||||
- PUP(out) = PUP(from);
|
|
||||||
- PUP(out) = PUP(from);
|
|
||||||
+ *out++ = *from++;
|
|
||||||
+ *out++ = *from++;
|
|
||||||
+ *out++ = *from++;
|
|
||||||
len -= 3;
|
|
||||||
}
|
|
||||||
if (len) {
|
|
||||||
- PUP(out) = PUP(from);
|
|
||||||
+ *out++ = *from++;
|
|
||||||
if (len > 1)
|
|
||||||
- PUP(out) = PUP(from);
|
|
||||||
+ *out++ = *from++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
@@ -259,25 +240,25 @@ void inflate_fast(z_streamp strm, unsigned start)
|
|
||||||
from = out - dist; /* copy direct from output */
|
|
||||||
/* minimum length is three */
|
|
||||||
/* Align out addr */
|
|
||||||
- if (!((long)(out - 1 + OFF) & 1)) {
|
|
||||||
- PUP(out) = PUP(from);
|
|
||||||
+ if (!((long)(out - 1) & 1)) {
|
|
||||||
+ *out++ = *from++;
|
|
||||||
len--;
|
|
||||||
}
|
|
||||||
- sout = (unsigned short *)(out - OFF);
|
|
||||||
+ sout = (unsigned short *)(out);
|
|
||||||
if (dist > 2 ) {
|
|
||||||
unsigned short *sfrom;
|
|
||||||
|
|
||||||
- sfrom = (unsigned short *)(from - OFF);
|
|
||||||
+ sfrom = (unsigned short *)(from);
|
|
||||||
loops = len >> 1;
|
|
||||||
do
|
|
||||||
- PUP(sout) = get_unaligned(++sfrom);
|
|
||||||
+ *sout++ = get_unaligned(++sfrom);
|
|
||||||
while (--loops);
|
|
||||||
- out = (unsigned char *)sout + OFF;
|
|
||||||
- from = (unsigned char *)sfrom + OFF;
|
|
||||||
+ out = (unsigned char *)sout;
|
|
||||||
+ from = (unsigned char *)sfrom;
|
|
||||||
} else { /* dist == 1 or dist == 2 */
|
|
||||||
unsigned short pat16;
|
|
||||||
|
|
||||||
- pat16 = *(sout-2+2*OFF);
|
|
||||||
+ pat16 = *(sout-2);
|
|
||||||
if (dist == 1)
|
|
||||||
#if defined(__BIG_ENDIAN)
|
|
||||||
pat16 = (pat16 & 0xff) | ((pat16 & 0xff ) << 8);
|
|
||||||
@@ -288,12 +269,12 @@ void inflate_fast(z_streamp strm, unsigned start)
|
|
||||||
#endif
|
|
||||||
loops = len >> 1;
|
|
||||||
do
|
|
||||||
- PUP(sout) = pat16;
|
|
||||||
+ *sout++ = pat16;
|
|
||||||
while (--loops);
|
|
||||||
- out = (unsigned char *)sout + OFF;
|
|
||||||
+ out = (unsigned char *)sout;
|
|
||||||
}
|
|
||||||
if (len & 1)
|
|
||||||
- PUP(out) = PUP(from);
|
|
||||||
+ *out++ = *from++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if ((op & 64) == 0) { /* 2nd level distance code */
|
|
||||||
@@ -329,8 +310,8 @@ void inflate_fast(z_streamp strm, unsigned start)
|
|
||||||
hold &= (1U << bits) - 1;
|
|
||||||
|
|
||||||
/* update state and return */
|
|
||||||
- strm->next_in = in + OFF;
|
|
||||||
- strm->next_out = out + OFF;
|
|
||||||
+ strm->next_in = in;
|
|
||||||
+ strm->next_out = out;
|
|
||||||
strm->avail_in = (unsigned)(in < last ? 5 + (last - in) : 5 - (in - last));
|
|
||||||
strm->avail_out = (unsigned)(out < end ?
|
|
||||||
257 + (end - out) : 257 - (out - end));
|
|
||||||
--
|
|
||||||
1.9.1
|
|
||||||
|
|
||||||
@ -1,64 +0,0 @@
|
|||||||
From c950cda47386360e37a89dfa7029d83e33888a40 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Keqian Zhu <zhukeqian1@huawei.com>
|
|
||||||
Date: Fri, 10 Apr 2020 13:04:40 +0800
|
|
||||||
Subject: [PATCH] accel/kvm: Add pre-park vCPU support
|
|
||||||
|
|
||||||
For that KVM do not support dynamic adjustment of vCPU count,
|
|
||||||
we must pre-park all possible vCPU at start.
|
|
||||||
|
|
||||||
Signed-off-by: Keqian Zhu <zhukeqian1@huawei.com>
|
|
||||||
Signed-off-by: Salil Mehta <salil.mehta@huawei.com>
|
|
||||||
---
|
|
||||||
accel/kvm/kvm-all.c | 23 +++++++++++++++++++++++
|
|
||||||
include/sysemu/kvm.h | 1 +
|
|
||||||
2 files changed, 24 insertions(+)
|
|
||||||
|
|
||||||
diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
|
|
||||||
index 8a98446b7c..f2ce5cd45a 100644
|
|
||||||
--- a/accel/kvm/kvm-all.c
|
|
||||||
+++ b/accel/kvm/kvm-all.c
|
|
||||||
@@ -433,6 +433,29 @@ void kvm_destroy_vcpu(CPUState *cpu)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
+int kvm_create_parked_vcpu(unsigned long vcpu_id)
|
|
||||||
+{
|
|
||||||
+ KVMState *s = kvm_state;
|
|
||||||
+ struct KVMParkedVcpu *vcpu = NULL;
|
|
||||||
+ int ret;
|
|
||||||
+
|
|
||||||
+ DPRINTF("kvm_create_parked_vcpu\n");
|
|
||||||
+
|
|
||||||
+ ret = kvm_vm_ioctl(s, KVM_CREATE_VCPU, (void *)vcpu_id);
|
|
||||||
+ if (ret < 0) {
|
|
||||||
+ DPRINTF("kvm_create_vcpu failed\n");
|
|
||||||
+ goto err;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ vcpu = g_malloc0(sizeof(*vcpu));
|
|
||||||
+ vcpu->vcpu_id = vcpu_id;
|
|
||||||
+ vcpu->kvm_fd = ret;
|
|
||||||
+ QLIST_INSERT_HEAD(&s->kvm_parked_vcpus, vcpu, node);
|
|
||||||
+
|
|
||||||
+err:
|
|
||||||
+ return ret;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
static int kvm_get_vcpu(KVMState *s, unsigned long vcpu_id)
|
|
||||||
{
|
|
||||||
struct KVMParkedVcpu *cpu;
|
|
||||||
diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h
|
|
||||||
index 7b22aeb6ae..2623775c27 100644
|
|
||||||
--- a/include/sysemu/kvm.h
|
|
||||||
+++ b/include/sysemu/kvm.h
|
|
||||||
@@ -221,6 +221,7 @@ int kvm_has_pit_state2(void);
|
|
||||||
int kvm_has_many_ioeventfds(void);
|
|
||||||
int kvm_has_gsi_routing(void);
|
|
||||||
int kvm_has_intx_set_mask(void);
|
|
||||||
+int kvm_create_parked_vcpu(unsigned long vcpu_id);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* kvm_arm_supports_user_irq
|
|
||||||
--
|
|
||||||
2.27.0
|
|
||||||
|
|
||||||
@ -1,35 +0,0 @@
|
|||||||
From 6ccda2ece6d08b1bf0622109c2a1f3eeca813089 Mon Sep 17 00:00:00 2001
|
|
||||||
From: qihao <qihao_yewu@cmss.chinamobile.com>
|
|
||||||
Date: Mon, 28 Aug 2023 19:43:06 +0800
|
|
||||||
Subject: [PATCH] accel/kvm: Free as when an error occurred
|
|
||||||
|
|
||||||
cheery-pick from 4625742cd2aeb1400407889a2f7a5b4c75437818
|
|
||||||
|
|
||||||
An error may occur after s->as is allocated, for example if the
|
|
||||||
KVM_CREATE_VM ioctl call fails.
|
|
||||||
|
|
||||||
Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
|
|
||||||
Message-id: 20230727073134.134102-6-akihiko.odaki@daynix.com
|
|
||||||
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
|
|
||||||
[PMM: tweaked commit message]
|
|
||||||
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
|
|
||||||
Signed-off-by: qihao_yewu <qihao_yewu@cmss.chinamobile.com>
|
|
||||||
---
|
|
||||||
accel/kvm/kvm-all.c | 1 +
|
|
||||||
1 file changed, 1 insertion(+)
|
|
||||||
|
|
||||||
diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
|
|
||||||
index 799d993f6c..9c8d3a916e 100644
|
|
||||||
--- a/accel/kvm/kvm-all.c
|
|
||||||
+++ b/accel/kvm/kvm-all.c
|
|
||||||
@@ -2589,6 +2589,7 @@ err:
|
|
||||||
if (s->fd != -1) {
|
|
||||||
close(s->fd);
|
|
||||||
}
|
|
||||||
+ g_free(s->as);
|
|
||||||
g_free(s->memory_listener.slots);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
--
|
|
||||||
2.41.0.windows.1
|
|
||||||
|
|
||||||
@ -1,58 +0,0 @@
|
|||||||
From e11f4d10f843f46a8659d0134220f8712f15b451 Mon Sep 17 00:00:00 2001
|
|
||||||
From: qihao <qihao_yewu@cmss.chinamobile.com>
|
|
||||||
Date: Mon, 28 Aug 2023 19:04:32 +0800
|
|
||||||
Subject: [PATCH] accel/kvm: Make kvm_dirty_ring_reaper_init() void
|
|
||||||
MIME-Version: 1.0
|
|
||||||
Content-Type: text/plain; charset=UTF-8
|
|
||||||
Content-Transfer-Encoding: 8bit
|
|
||||||
|
|
||||||
cheery-pick from 43a5e377f42d1d3ed12ea562196f723b354ce411
|
|
||||||
|
|
||||||
The returned value was always zero and had no meaning.
|
|
||||||
|
|
||||||
Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
|
|
||||||
Message-id: 20230727073134.134102-7-akihiko.odaki@daynix.com
|
|
||||||
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
|
|
||||||
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
|
|
||||||
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
|
|
||||||
Signed-off-by: qihao_yewu <qihao_yewu@cmss.chinamobile.com>
|
|
||||||
---
|
|
||||||
accel/kvm/kvm-all.c | 9 ++-------
|
|
||||||
1 file changed, 2 insertions(+), 7 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
|
|
||||||
index 799d993f6c..83881e1d96 100644
|
|
||||||
--- a/accel/kvm/kvm-all.c
|
|
||||||
+++ b/accel/kvm/kvm-all.c
|
|
||||||
@@ -1436,15 +1436,13 @@ static void *kvm_dirty_ring_reaper_thread(void *data)
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
-static int kvm_dirty_ring_reaper_init(KVMState *s)
|
|
||||||
+static void kvm_dirty_ring_reaper_init(KVMState *s)
|
|
||||||
{
|
|
||||||
struct KVMDirtyRingReaper *r = &s->reaper;
|
|
||||||
|
|
||||||
qemu_thread_create(&r->reaper_thr, "kvm-reaper",
|
|
||||||
kvm_dirty_ring_reaper_thread,
|
|
||||||
s, QEMU_THREAD_JOINABLE);
|
|
||||||
-
|
|
||||||
- return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void kvm_region_add(MemoryListener *listener,
|
|
||||||
@@ -2573,10 +2571,7 @@ static int kvm_init(MachineState *ms)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (s->kvm_dirty_ring_size) {
|
|
||||||
- ret = kvm_dirty_ring_reaper_init(s);
|
|
||||||
- if (ret) {
|
|
||||||
- goto err;
|
|
||||||
- }
|
|
||||||
+ kvm_dirty_ring_reaper_init(s);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
--
|
|
||||||
2.41.0.windows.1
|
|
||||||
|
|
||||||
@ -1,66 +0,0 @@
|
|||||||
From 85583352f3bc28badd4cb336517f6a4eb440d5b0 Mon Sep 17 00:00:00 2001
|
|
||||||
From: =?UTF-8?q?Hyman=20Huang=28=E9=BB=84=E5=8B=87=29?=
|
|
||||||
<huangy81@chinatelecom.cn>
|
|
||||||
Date: Sun, 26 Jun 2022 01:38:34 +0800
|
|
||||||
Subject: [PATCH 2/3] accel/kvm/kvm-all: Introduce kvm_dirty_ring_size function
|
|
||||||
MIME-Version: 1.0
|
|
||||||
Content-Type: text/plain; charset=UTF-8
|
|
||||||
Content-Transfer-Encoding: 8bit
|
|
||||||
|
|
||||||
Introduce kvm_dirty_ring_size util function to help calculate
|
|
||||||
dirty ring ful time.
|
|
||||||
|
|
||||||
Signed-off-by: Hyman Huang(黄勇) <huangy81@chinatelecom.cn>
|
|
||||||
Acked-by: Peter Xu <peterx@redhat.com>
|
|
||||||
Message-Id: <f9ce1f550bfc0e3a1f711e17b1dbc8f701700e56.1656177590.git.huangy81@chinatelecom.cn>
|
|
||||||
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
|
|
||||||
---
|
|
||||||
accel/kvm/kvm-all.c | 5 +++++
|
|
||||||
accel/stubs/kvm-stub.c | 5 +++++
|
|
||||||
include/sysemu/kvm.h | 2 ++
|
|
||||||
3 files changed, 12 insertions(+)
|
|
||||||
|
|
||||||
diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
|
|
||||||
index 3bc6eb6294..d0c4310507 100644
|
|
||||||
--- a/accel/kvm/kvm-all.c
|
|
||||||
+++ b/accel/kvm/kvm-all.c
|
|
||||||
@@ -2332,6 +2332,11 @@ bool kvm_dirty_ring_enabled(void)
|
|
||||||
return kvm_state->kvm_dirty_ring_size ? true : false;
|
|
||||||
}
|
|
||||||
|
|
||||||
+uint32_t kvm_dirty_ring_size(void)
|
|
||||||
+{
|
|
||||||
+ return kvm_state->kvm_dirty_ring_size;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
static int kvm_init(MachineState *ms)
|
|
||||||
{
|
|
||||||
MachineClass *mc = MACHINE_GET_CLASS(ms);
|
|
||||||
diff --git a/accel/stubs/kvm-stub.c b/accel/stubs/kvm-stub.c
|
|
||||||
index 5319573e00..1128cb2928 100644
|
|
||||||
--- a/accel/stubs/kvm-stub.c
|
|
||||||
+++ b/accel/stubs/kvm-stub.c
|
|
||||||
@@ -152,4 +152,9 @@ bool kvm_dirty_ring_enabled(void)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
+
|
|
||||||
+uint32_t kvm_dirty_ring_size(void)
|
|
||||||
+{
|
|
||||||
+ return 0;
|
|
||||||
+}
|
|
||||||
#endif
|
|
||||||
diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h
|
|
||||||
index 2623775c27..19c5c8402a 100644
|
|
||||||
--- a/include/sysemu/kvm.h
|
|
||||||
+++ b/include/sysemu/kvm.h
|
|
||||||
@@ -549,4 +549,6 @@ bool kvm_cpu_check_are_resettable(void);
|
|
||||||
bool kvm_arch_cpu_check_are_resettable(void);
|
|
||||||
|
|
||||||
bool kvm_dirty_ring_enabled(void);
|
|
||||||
+
|
|
||||||
+uint32_t kvm_dirty_ring_size(void);
|
|
||||||
#endif
|
|
||||||
--
|
|
||||||
2.27.0
|
|
||||||
|
|
||||||
@ -1,106 +0,0 @@
|
|||||||
From c6f781e50e75fc2e6b819291b6c5ce6c212f018b Mon Sep 17 00:00:00 2001
|
|
||||||
From: =?UTF-8?q?Hyman=20Huang=28=E9=BB=84=E5=8B=87=29?=
|
|
||||||
<huangy81@chinatelecom.cn>
|
|
||||||
Date: Sun, 26 Jun 2022 01:38:30 +0800
|
|
||||||
Subject: [PATCH 1/3] accel/kvm/kvm-all: Refactor per-vcpu dirty ring reaping
|
|
||||||
MIME-Version: 1.0
|
|
||||||
Content-Type: text/plain; charset=UTF-8
|
|
||||||
Content-Transfer-Encoding: 8bit
|
|
||||||
|
|
||||||
Add a non-required argument 'CPUState' to kvm_dirty_ring_reap so
|
|
||||||
that it can cover single vcpu dirty-ring-reaping scenario.
|
|
||||||
|
|
||||||
Signed-off-by: Hyman Huang(黄勇) <huangy81@chinatelecom.cn>
|
|
||||||
Reviewed-by: Peter Xu <peterx@redhat.com>
|
|
||||||
Message-Id: <c32001242875e83b0d9f78f396fe2dcd380ba9e8.1656177590.git.huangy81@chinatelecom.cn>
|
|
||||||
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
|
|
||||||
---
|
|
||||||
accel/kvm/kvm-all.c | 23 +++++++++++++----------
|
|
||||||
1 file changed, 13 insertions(+), 10 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
|
|
||||||
index f2ce5cd45a..3bc6eb6294 100644
|
|
||||||
--- a/accel/kvm/kvm-all.c
|
|
||||||
+++ b/accel/kvm/kvm-all.c
|
|
||||||
@@ -773,17 +773,20 @@ static uint32_t kvm_dirty_ring_reap_one(KVMState *s, CPUState *cpu)
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Must be with slots_lock held */
|
|
||||||
-static uint64_t kvm_dirty_ring_reap_locked(KVMState *s)
|
|
||||||
+static uint64_t kvm_dirty_ring_reap_locked(KVMState *s, CPUState* cpu)
|
|
||||||
{
|
|
||||||
int ret;
|
|
||||||
- CPUState *cpu;
|
|
||||||
uint64_t total = 0;
|
|
||||||
int64_t stamp;
|
|
||||||
|
|
||||||
stamp = get_clock();
|
|
||||||
|
|
||||||
- CPU_FOREACH(cpu) {
|
|
||||||
- total += kvm_dirty_ring_reap_one(s, cpu);
|
|
||||||
+ if (cpu) {
|
|
||||||
+ total = kvm_dirty_ring_reap_one(s, cpu);
|
|
||||||
+ } else {
|
|
||||||
+ CPU_FOREACH(cpu) {
|
|
||||||
+ total += kvm_dirty_ring_reap_one(s, cpu);
|
|
||||||
+ }
|
|
||||||
}
|
|
||||||
|
|
||||||
if (total) {
|
|
||||||
@@ -804,7 +807,7 @@ static uint64_t kvm_dirty_ring_reap_locked(KVMState *s)
|
|
||||||
* Currently for simplicity, we must hold BQL before calling this. We can
|
|
||||||
* consider to drop the BQL if we're clear with all the race conditions.
|
|
||||||
*/
|
|
||||||
-static uint64_t kvm_dirty_ring_reap(KVMState *s)
|
|
||||||
+static uint64_t kvm_dirty_ring_reap(KVMState *s, CPUState *cpu)
|
|
||||||
{
|
|
||||||
uint64_t total;
|
|
||||||
|
|
||||||
@@ -824,7 +827,7 @@ static uint64_t kvm_dirty_ring_reap(KVMState *s)
|
|
||||||
* reset below.
|
|
||||||
*/
|
|
||||||
kvm_slots_lock();
|
|
||||||
- total = kvm_dirty_ring_reap_locked(s);
|
|
||||||
+ total = kvm_dirty_ring_reap_locked(s, cpu);
|
|
||||||
kvm_slots_unlock();
|
|
||||||
|
|
||||||
return total;
|
|
||||||
@@ -871,7 +874,7 @@ static void kvm_dirty_ring_flush(void)
|
|
||||||
* vcpus out in a synchronous way.
|
|
||||||
*/
|
|
||||||
kvm_cpu_synchronize_kick_all();
|
|
||||||
- kvm_dirty_ring_reap(kvm_state);
|
|
||||||
+ kvm_dirty_ring_reap(kvm_state, NULL);
|
|
||||||
trace_kvm_dirty_ring_flush(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1415,7 +1418,7 @@ static void kvm_set_phys_mem(KVMMemoryListener *kml,
|
|
||||||
* Not easy. Let's cross the fingers until it's fixed.
|
|
||||||
*/
|
|
||||||
if (kvm_state->kvm_dirty_ring_size) {
|
|
||||||
- kvm_dirty_ring_reap_locked(kvm_state);
|
|
||||||
+ kvm_dirty_ring_reap_locked(kvm_state, NULL);
|
|
||||||
} else {
|
|
||||||
kvm_slot_get_dirty_log(kvm_state, mem);
|
|
||||||
}
|
|
||||||
@@ -1487,7 +1490,7 @@ static void *kvm_dirty_ring_reaper_thread(void *data)
|
|
||||||
r->reaper_state = KVM_DIRTY_RING_REAPER_REAPING;
|
|
||||||
|
|
||||||
qemu_mutex_lock_iothread();
|
|
||||||
- kvm_dirty_ring_reap(s);
|
|
||||||
+ kvm_dirty_ring_reap(s, NULL);
|
|
||||||
qemu_mutex_unlock_iothread();
|
|
||||||
|
|
||||||
r->reaper_iteration++;
|
|
||||||
@@ -2957,7 +2960,7 @@ int kvm_cpu_exec(CPUState *cpu)
|
|
||||||
*/
|
|
||||||
trace_kvm_dirty_ring_full(cpu->cpu_index);
|
|
||||||
qemu_mutex_lock_iothread();
|
|
||||||
- kvm_dirty_ring_reap(kvm_state);
|
|
||||||
+ kvm_dirty_ring_reap(kvm_state, NULL);
|
|
||||||
qemu_mutex_unlock_iothread();
|
|
||||||
ret = 0;
|
|
||||||
break;
|
|
||||||
--
|
|
||||||
2.27.0
|
|
||||||
|
|
||||||
@ -1,49 +0,0 @@
|
|||||||
From 28ca488c585c556ce04419f927d13d46771e1ea4 Mon Sep 17 00:00:00 2001
|
|
||||||
From: tangbinzy <tangbin_yewu@cmss.chinamobile.com>
|
|
||||||
Date: Tue, 18 Jul 2023 06:29:51 +0000
|
|
||||||
Subject: [PATCH] accel/tcg: Optimize jump cache flush during tlb range flush
|
|
||||||
mainline inclusion commit cfc2a2d69d59f02b32df3098ce17e10ab86d43c6 category:
|
|
||||||
bugfix
|
|
||||||
|
|
||||||
---------------------------------------------------------------
|
|
||||||
|
|
||||||
When the length of the range is large enough, clearing the whole cache is
|
|
||||||
faster than iterating over the (possibly extremely large) set of pages
|
|
||||||
contained in the range.
|
|
||||||
|
|
||||||
This mimics the pre-existing similar optimization done on the flush of the
|
|
||||||
tlb itself.
|
|
||||||
|
|
||||||
Signed-off-by: Idan Horowitz <idan.horowitz@gmail.com>
|
|
||||||
Message-Id: <20220110164754.1066025-1-idan.horowitz@gmail.com>
|
|
||||||
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
|
|
||||||
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
|
|
||||||
|
|
||||||
Signed-off-by: tangbinzy <tangbin_yewu@cmss.chinamobile.com>
|
|
||||||
---
|
|
||||||
accel/tcg/cputlb.c | 9 +++++++++
|
|
||||||
1 file changed, 9 insertions(+)
|
|
||||||
|
|
||||||
diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c
|
|
||||||
index b69a953447..03526fa1ab 100644
|
|
||||||
--- a/accel/tcg/cputlb.c
|
|
||||||
+++ b/accel/tcg/cputlb.c
|
|
||||||
@@ -783,6 +783,15 @@ static void tlb_flush_range_by_mmuidx_async_0(CPUState *cpu,
|
|
||||||
}
|
|
||||||
qemu_spin_unlock(&env_tlb(env)->c.lock);
|
|
||||||
|
|
||||||
+ /*
|
|
||||||
+ * If the length is larger than the jump cache size, then it will take
|
|
||||||
+ * longer to clear each entry individually than it will to clear it all.
|
|
||||||
+ */
|
|
||||||
+ if (d.len >= (TARGET_PAGE_SIZE * TB_JMP_CACHE_SIZE)) {
|
|
||||||
+ cpu_tb_jmp_cache_clear(cpu);
|
|
||||||
+ return;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
for (target_ulong i = 0; i < d.len; i += TARGET_PAGE_SIZE) {
|
|
||||||
tb_flush_jmp_cache(cpu, d.addr + i);
|
|
||||||
}
|
|
||||||
--
|
|
||||||
2.41.0.windows.1
|
|
||||||
|
|
||||||
@ -1,48 +0,0 @@
|
|||||||
From ddca9c0cba8e3c858b7998c67ae2739f58b5b681 Mon Sep 17 00:00:00 2001
|
|
||||||
From: tangbinzy <tangbin_yewu@cmss.chinamobile.com>
|
|
||||||
Date: Fri, 21 Jul 2023 06:41:38 +0000
|
|
||||||
Subject: [PATCH] accel/tcg/cpu-exec: Fix precise single-stepping after
|
|
||||||
interrupt mainline inclusion commit 5b7b197c87cefbd24bd1936614fd4e00ccc279ab
|
|
||||||
category: bugfix
|
|
||||||
|
|
||||||
---------------------------------------------------------------
|
|
||||||
|
|
||||||
In some cases, cpu->exit_request can be false after handling the
|
|
||||||
interrupt, leading to another TB being executed instead of returning
|
|
||||||
to the main loop.
|
|
||||||
|
|
||||||
Fix this by returning true unconditionally when in single-step mode.
|
|
||||||
|
|
||||||
Fixes: ba3c35d9c402 ("tcg/cpu-exec: precise single-stepping after an interrupt")
|
|
||||||
Signed-off-by: Luc Michel <lmichel@kalray.eu>
|
|
||||||
Message-Id: <20220214132656.11397-1-lmichel@kalray.eu>
|
|
||||||
[rth: Unlock iothread mutex; simplify indentation]
|
|
||||||
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
|
|
||||||
|
|
||||||
Signed-off-by: tangbinzy <tangbin_yewu@cmss.chinamobile.com>
|
|
||||||
---
|
|
||||||
accel/tcg/cpu-exec.c | 8 ++++++--
|
|
||||||
1 file changed, 6 insertions(+), 2 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c
|
|
||||||
index 409ec8c38c..7fb87afedc 100644
|
|
||||||
--- a/accel/tcg/cpu-exec.c
|
|
||||||
+++ b/accel/tcg/cpu-exec.c
|
|
||||||
@@ -798,8 +798,12 @@ static inline bool cpu_handle_interrupt(CPUState *cpu,
|
|
||||||
* raised when single-stepping so that GDB doesn't miss the
|
|
||||||
* next instruction.
|
|
||||||
*/
|
|
||||||
- cpu->exception_index =
|
|
||||||
- (cpu->singlestep_enabled ? EXCP_DEBUG : -1);
|
|
||||||
+ if (unlikely(cpu->singlestep_enabled)) {
|
|
||||||
+ cpu->exception_index = EXCP_DEBUG;
|
|
||||||
+ qemu_mutex_unlock_iothread();
|
|
||||||
+ return true;
|
|
||||||
+ }
|
|
||||||
+ cpu->exception_index = -1;
|
|
||||||
*last_tb = NULL;
|
|
||||||
}
|
|
||||||
/* The target hook may have updated the 'cpu->interrupt_request';
|
|
||||||
--
|
|
||||||
2.41.0.windows.1
|
|
||||||
|
|
||||||
@ -1,117 +0,0 @@
|
|||||||
From 1ab75151c0a486ebdbe50d29c9677c7bc1f05929 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Keqian Zhu <zhukeqian1@huawei.com>
|
|
||||||
Date: Wed, 22 Apr 2020 16:11:13 +0800
|
|
||||||
Subject: [PATCH] acpi/cpu: Prepare build_cpus_aml for arm virt
|
|
||||||
|
|
||||||
We will reuse build_cpus_aml to build DSDT cpus aml in arm/virt
|
|
||||||
ACPI to realize cpu hotplug. Three points are added.
|
|
||||||
|
|
||||||
1. Make ACPI IO address space configurable, because ARM64 platforms
|
|
||||||
don't use port IO for ACPI IO space.
|
|
||||||
2. Add GICC struct building support in _MAT of cpu aml.
|
|
||||||
3. Let the hotplug method parameter can be NULL, because ACPI GED
|
|
||||||
will realize it.
|
|
||||||
|
|
||||||
Besides, CPU CPPC building is injected.
|
|
||||||
|
|
||||||
Signed-off-by: Keqian Zhu <zhukeqian1@huawei.com>
|
|
||||||
Signed-off-by: Salil Mehta <salil.mehta@huawei.com>
|
|
||||||
---
|
|
||||||
hw/acpi/cpu.c | 27 ++++++++++++++++++++-------
|
|
||||||
hw/i386/acpi-build.c | 2 +-
|
|
||||||
include/hw/acpi/cpu.h | 3 ++-
|
|
||||||
3 files changed, 23 insertions(+), 9 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/hw/acpi/cpu.c b/hw/acpi/cpu.c
|
|
||||||
index b20903ea30..a9c2ee952a 100644
|
|
||||||
--- a/hw/acpi/cpu.c
|
|
||||||
+++ b/hw/acpi/cpu.c
|
|
||||||
@@ -343,7 +343,8 @@ const VMStateDescription vmstate_cpu_hotplug = {
|
|
||||||
void build_cpus_aml(Aml *table, MachineState *machine, CPUHotplugFeatures opts,
|
|
||||||
hwaddr io_base,
|
|
||||||
const char *res_root,
|
|
||||||
- const char *event_handler_method)
|
|
||||||
+ const char *event_handler_method,
|
|
||||||
+ AmlRegionSpace rs)
|
|
||||||
{
|
|
||||||
Aml *ifctx;
|
|
||||||
Aml *field;
|
|
||||||
@@ -371,13 +372,18 @@ void build_cpus_aml(Aml *table, MachineState *machine, CPUHotplugFeatures opts,
|
|
||||||
aml_append(cpu_ctrl_dev, aml_mutex(CPU_LOCK, 0));
|
|
||||||
|
|
||||||
crs = aml_resource_template();
|
|
||||||
- aml_append(crs, aml_io(AML_DECODE16, io_base, io_base, 1,
|
|
||||||
- ACPI_CPU_HOTPLUG_REG_LEN));
|
|
||||||
+ if (rs == AML_SYSTEM_IO) {
|
|
||||||
+ aml_append(crs, aml_io(AML_DECODE16, io_base, io_base, 1,
|
|
||||||
+ ACPI_CPU_HOTPLUG_REG_LEN));
|
|
||||||
+ } else {
|
|
||||||
+ aml_append(crs, aml_memory32_fixed(io_base,
|
|
||||||
+ ACPI_CPU_HOTPLUG_REG_LEN, AML_READ_WRITE));
|
|
||||||
+ }
|
|
||||||
aml_append(cpu_ctrl_dev, aml_name_decl("_CRS", crs));
|
|
||||||
|
|
||||||
/* declare CPU hotplug MMIO region with related access fields */
|
|
||||||
aml_append(cpu_ctrl_dev,
|
|
||||||
- aml_operation_region("PRST", AML_SYSTEM_IO, aml_int(io_base),
|
|
||||||
+ aml_operation_region("PRST", rs, aml_int(io_base),
|
|
||||||
ACPI_CPU_HOTPLUG_REG_LEN));
|
|
||||||
|
|
||||||
field = aml_field("PRST", AML_BYTE_ACC, AML_NOLOCK,
|
|
||||||
@@ -663,6 +669,11 @@ void build_cpus_aml(Aml *table, MachineState *machine, CPUHotplugFeatures opts,
|
|
||||||
aml_append(dev, aml_name_decl("_UID", uid));
|
|
||||||
}
|
|
||||||
|
|
||||||
+ assert(adevc);
|
|
||||||
+ if (adevc->cpu_cppc) {
|
|
||||||
+ adevc->cpu_cppc(adev, i, arch_ids->len, dev);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
method = aml_method("_STA", 0, AML_SERIALIZED);
|
|
||||||
aml_append(method, aml_return(aml_call1(CPU_STS_METHOD, uid)));
|
|
||||||
aml_append(dev, method);
|
|
||||||
@@ -703,9 +714,11 @@ void build_cpus_aml(Aml *table, MachineState *machine, CPUHotplugFeatures opts,
|
|
||||||
aml_append(sb_scope, cpus_dev);
|
|
||||||
aml_append(table, sb_scope);
|
|
||||||
|
|
||||||
- method = aml_method(event_handler_method, 0, AML_NOTSERIALIZED);
|
|
||||||
- aml_append(method, aml_call0("\\_SB.CPUS." CPU_SCAN_METHOD));
|
|
||||||
- aml_append(table, method);
|
|
||||||
+ if (event_handler_method) {
|
|
||||||
+ method = aml_method(event_handler_method, 0, AML_NOTSERIALIZED);
|
|
||||||
+ aml_append(method, aml_call0("\\_SB.CPUS." CPU_SCAN_METHOD));
|
|
||||||
+ aml_append(table, method);
|
|
||||||
+ }
|
|
||||||
|
|
||||||
g_free(cphp_res_path);
|
|
||||||
}
|
|
||||||
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
|
|
||||||
index a99c6e4fe3..1ce2d67c2e 100644
|
|
||||||
--- a/hw/i386/acpi-build.c
|
|
||||||
+++ b/hw/i386/acpi-build.c
|
|
||||||
@@ -1513,7 +1513,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
|
|
||||||
.fw_unplugs_cpu = pm->smi_on_cpu_unplug,
|
|
||||||
};
|
|
||||||
build_cpus_aml(dsdt, machine, opts, pm->cpu_hp_io_base,
|
|
||||||
- "\\_SB.PCI0", "\\_GPE._E02");
|
|
||||||
+ "\\_SB.PCI0", "\\_GPE._E02", AML_SYSTEM_IO);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pcms->memhp_io_base && nr_mem) {
|
|
||||||
diff --git a/include/hw/acpi/cpu.h b/include/hw/acpi/cpu.h
|
|
||||||
index 999caaf510..a0fdc44bdd 100644
|
|
||||||
--- a/include/hw/acpi/cpu.h
|
|
||||||
+++ b/include/hw/acpi/cpu.h
|
|
||||||
@@ -58,7 +58,8 @@ typedef struct CPUHotplugFeatures {
|
|
||||||
void build_cpus_aml(Aml *table, MachineState *machine, CPUHotplugFeatures opts,
|
|
||||||
hwaddr io_base,
|
|
||||||
const char *res_root,
|
|
||||||
- const char *event_handler_method);
|
|
||||||
+ const char *event_handler_method,
|
|
||||||
+ AmlRegionSpace rs);
|
|
||||||
|
|
||||||
void acpi_cpu_ospm_status(CPUHotplugState *cpu_st, ACPIOSTInfoList ***list);
|
|
||||||
|
|
||||||
--
|
|
||||||
2.27.0
|
|
||||||
|
|
||||||
@ -1,90 +0,0 @@
|
|||||||
From ad7b272f693e2fbf4a74c47f566b6c3f8c27247c Mon Sep 17 00:00:00 2001
|
|
||||||
From: Igor Mammedov <imammedo@redhat.com>
|
|
||||||
Date: Mon, 27 Dec 2021 14:31:17 -0500
|
|
||||||
Subject: [PATCH 1/6] acpi: fix QEMU crash when started with SLIC table
|
|
||||||
MIME-Version: 1.0
|
|
||||||
Content-Type: text/plain; charset=UTF-8
|
|
||||||
Content-Transfer-Encoding: 8bit
|
|
||||||
|
|
||||||
if QEMU is started with used provided SLIC table blob,
|
|
||||||
|
|
||||||
-acpitable sig=SLIC,oem_id='CRASH ',oem_table_id="ME",oem_rev=00002210,asl_compiler_id="",asl_compiler_rev=00000000,data=/dev/null
|
|
||||||
it will assert with:
|
|
||||||
|
|
||||||
hw/acpi/aml-build.c:61:build_append_padded_str: assertion failed: (len <= maxlen)
|
|
||||||
|
|
||||||
and following backtrace:
|
|
||||||
|
|
||||||
...
|
|
||||||
build_append_padded_str (array=0x555556afe320, str=0x555556afdb2e "CRASH ME", maxlen=0x6, pad=0x20) at hw/acpi/aml-build.c:61
|
|
||||||
acpi_table_begin (desc=0x7fffffffd1b0, array=0x555556afe320) at hw/acpi/aml-build.c:1727
|
|
||||||
build_fadt (tbl=0x555556afe320, linker=0x555557ca3830, f=0x7fffffffd318, oem_id=0x555556afdb2e "CRASH ME", oem_table_id=0x555556afdb34 "ME") at hw/acpi/aml-build.c:2064
|
|
||||||
...
|
|
||||||
|
|
||||||
which happens due to acpi_table_begin() expecting NULL terminated
|
|
||||||
oem_id and oem_table_id strings, which is normally the case, but
|
|
||||||
in case of user provided SLIC table, oem_id points to table's blob
|
|
||||||
directly and as result oem_id became longer than expected.
|
|
||||||
|
|
||||||
Fix issue by handling oem_id consistently and make acpi_get_slic_oem()
|
|
||||||
return NULL terminated strings.
|
|
||||||
|
|
||||||
PS:
|
|
||||||
After [1] refactoring, oem_id semantics became inconsistent, where
|
|
||||||
NULL terminated string was coming from machine and old way pointer
|
|
||||||
into byte array coming from -acpitable option. That used to work
|
|
||||||
since build_header() wasn't expecting NULL terminated string and
|
|
||||||
blindly copied the 1st 6 bytes only.
|
|
||||||
|
|
||||||
However commit [2] broke that by replacing build_header() with
|
|
||||||
acpi_table_begin(), which was expecting NULL terminated string
|
|
||||||
and was checking oem_id size.
|
|
||||||
|
|
||||||
1) 602b45820 ("acpi: Permit OEM ID and OEM table ID fields to be changed")
|
|
||||||
2)
|
|
||||||
Fixes: 4b56e1e4eb08 ("acpi: build_fadt: use acpi_table_begin()/acpi_table_end() instead of build_header()")
|
|
||||||
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/786
|
|
||||||
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
|
|
||||||
Message-Id: <20211227193120.1084176-2-imammedo@redhat.com>
|
|
||||||
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
|
|
||||||
Tested-by: Denis Lisov <dennis.lissov@gmail.com>
|
|
||||||
Tested-by: Alexander Tsoy <alexander@tsoy.me>
|
|
||||||
Cc: qemu-stable@nongnu.org
|
|
||||||
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
|
|
||||||
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
|
|
||||||
---
|
|
||||||
hw/acpi/core.c | 4 ++--
|
|
||||||
hw/i386/acpi-build.c | 2 ++
|
|
||||||
2 files changed, 4 insertions(+), 2 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/hw/acpi/core.c b/hw/acpi/core.c
|
|
||||||
index eb631caa91..a2d790d432 100644
|
|
||||||
--- a/hw/acpi/core.c
|
|
||||||
+++ b/hw/acpi/core.c
|
|
||||||
@@ -346,8 +346,8 @@ int acpi_get_slic_oem(AcpiSlicOem *oem)
|
|
||||||
struct acpi_table_header *hdr = (void *)(u - sizeof(hdr->_length));
|
|
||||||
|
|
||||||
if (memcmp(hdr->sig, "SLIC", 4) == 0) {
|
|
||||||
- oem->id = hdr->oem_id;
|
|
||||||
- oem->table_id = hdr->oem_table_id;
|
|
||||||
+ oem->id = g_strndup(hdr->oem_id, 6);
|
|
||||||
+ oem->table_id = g_strndup(hdr->oem_table_id, 8);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
|
|
||||||
index 1ce2d67c2e..0ec2932ec2 100644
|
|
||||||
--- a/hw/i386/acpi-build.c
|
|
||||||
+++ b/hw/i386/acpi-build.c
|
|
||||||
@@ -2721,6 +2721,8 @@ void acpi_build(AcpiBuildTables *tables, MachineState *machine)
|
|
||||||
|
|
||||||
/* Cleanup memory that's no longer used. */
|
|
||||||
g_array_free(table_offsets, true);
|
|
||||||
+ g_free(slic_oem.id);
|
|
||||||
+ g_free(slic_oem.table_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void acpi_ram_update(MemoryRegion *mr, GArray *data)
|
|
||||||
--
|
|
||||||
2.27.0
|
|
||||||
|
|
||||||
@ -1,205 +0,0 @@
|
|||||||
From 603cbcc5efdd35f518a5bd0a5067d40c2c4eb8d6 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Keqian Zhu <zhukeqian1@huawei.com>
|
|
||||||
Date: Fri, 3 Apr 2020 15:41:01 +0800
|
|
||||||
Subject: [PATCH] acpi/ged: Extend ACPI GED to support CPU hotplug
|
|
||||||
|
|
||||||
This adds a new GED event called ACPI_GED_CPU_HOTPLUG_EVT.
|
|
||||||
The basic workflow is that: GED sends this event to guest,
|
|
||||||
then ACPI driver in guest will call _EVT method of GED aml,
|
|
||||||
then _EVT will call CSCN method in cpus aml to get status of
|
|
||||||
all cpus.
|
|
||||||
|
|
||||||
The status of cpus is maintained by CPUHotplugState in GED and
|
|
||||||
is made accessable to guest through memory region.
|
|
||||||
|
|
||||||
This also adds migration support to CPUHotplugState.
|
|
||||||
|
|
||||||
Signed-off-by: Keqian Zhu <zhukeqian1@huawei.com>
|
|
||||||
Signed-off-by: Salil Mehta <salil.mehta@huawei.com>
|
|
||||||
---
|
|
||||||
docs/specs/acpi_hw_reduced_hotplug.rst | 3 ++-
|
|
||||||
hw/acpi/cpu.c | 1 -
|
|
||||||
hw/acpi/generic_event_device.c | 35 ++++++++++++++++++++++++++
|
|
||||||
hw/arm/Kconfig | 1 +
|
|
||||||
include/hw/acpi/cpu.h | 2 ++
|
|
||||||
include/hw/acpi/generic_event_device.h | 4 +++
|
|
||||||
6 files changed, 44 insertions(+), 2 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/docs/specs/acpi_hw_reduced_hotplug.rst b/docs/specs/acpi_hw_reduced_hotplug.rst
|
|
||||||
index 0bd3f9399f..3acd6fcd8b 100644
|
|
||||||
--- a/docs/specs/acpi_hw_reduced_hotplug.rst
|
|
||||||
+++ b/docs/specs/acpi_hw_reduced_hotplug.rst
|
|
||||||
@@ -64,7 +64,8 @@ GED IO interface (4 byte access)
|
|
||||||
0: Memory hotplug event
|
|
||||||
1: System power down event
|
|
||||||
2: NVDIMM hotplug event
|
|
||||||
- 3-31: Reserved
|
|
||||||
+ 3: CPU hotplug event
|
|
||||||
+ 4-31: Reserved
|
|
||||||
|
|
||||||
**write_access:**
|
|
||||||
|
|
||||||
diff --git a/hw/acpi/cpu.c b/hw/acpi/cpu.c
|
|
||||||
index a9c2ee952a..f9ce0a7f41 100644
|
|
||||||
--- a/hw/acpi/cpu.c
|
|
||||||
+++ b/hw/acpi/cpu.c
|
|
||||||
@@ -6,7 +6,6 @@
|
|
||||||
#include "trace.h"
|
|
||||||
#include "sysemu/numa.h"
|
|
||||||
|
|
||||||
-#define ACPI_CPU_HOTPLUG_REG_LEN 12
|
|
||||||
#define ACPI_CPU_SELECTOR_OFFSET_WR 0
|
|
||||||
#define ACPI_CPU_FLAGS_OFFSET_RW 4
|
|
||||||
#define ACPI_CPU_CMD_OFFSET_WR 5
|
|
||||||
diff --git a/hw/acpi/generic_event_device.c b/hw/acpi/generic_event_device.c
|
|
||||||
index e28457a7d1..042a8ef8a5 100644
|
|
||||||
--- a/hw/acpi/generic_event_device.c
|
|
||||||
+++ b/hw/acpi/generic_event_device.c
|
|
||||||
@@ -25,6 +25,7 @@ static const uint32_t ged_supported_events[] = {
|
|
||||||
ACPI_GED_MEM_HOTPLUG_EVT,
|
|
||||||
ACPI_GED_PWR_DOWN_EVT,
|
|
||||||
ACPI_GED_NVDIMM_HOTPLUG_EVT,
|
|
||||||
+ ACPI_GED_CPU_HOTPLUG_EVT,
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
@@ -117,6 +118,9 @@ void build_ged_aml(Aml *table, const char *name, HotplugHandler *hotplug_dev,
|
|
||||||
aml_notify(aml_name("\\_SB.NVDR"),
|
|
||||||
aml_int(0x80)));
|
|
||||||
break;
|
|
||||||
+ case ACPI_GED_CPU_HOTPLUG_EVT:
|
|
||||||
+ aml_append(if_ctx, aml_call0("\\_SB.CPUS.CSCN"));
|
|
||||||
+ break;
|
|
||||||
default:
|
|
||||||
/*
|
|
||||||
* Please make sure all the events in ged_supported_events[]
|
|
||||||
@@ -234,6 +238,8 @@ static void acpi_ged_device_plug_cb(HotplugHandler *hotplug_dev,
|
|
||||||
} else {
|
|
||||||
acpi_memory_plug_cb(hotplug_dev, &s->memhp_state, dev, errp);
|
|
||||||
}
|
|
||||||
+ } else if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) {
|
|
||||||
+ acpi_cpu_plug_cb(hotplug_dev, &s->cpuhp_state, dev, errp);
|
|
||||||
} else {
|
|
||||||
error_setg(errp, "virt: device plug request for unsupported device"
|
|
||||||
" type: %s", object_get_typename(OBJECT(dev)));
|
|
||||||
@@ -279,6 +285,8 @@ static void acpi_ged_send_event(AcpiDeviceIf *adev, AcpiEventStatusBits ev)
|
|
||||||
sel = ACPI_GED_PWR_DOWN_EVT;
|
|
||||||
} else if (ev & ACPI_NVDIMM_HOTPLUG_STATUS) {
|
|
||||||
sel = ACPI_GED_NVDIMM_HOTPLUG_EVT;
|
|
||||||
+ } else if (ev & ACPI_CPU_HOTPLUG_STATUS) {
|
|
||||||
+ sel = ACPI_GED_CPU_HOTPLUG_EVT;
|
|
||||||
} else {
|
|
||||||
/* Unknown event. Return without generating interrupt. */
|
|
||||||
warn_report("GED: Unsupported event %d. No irq injected", ev);
|
|
||||||
@@ -311,6 +319,16 @@ static const VMStateDescription vmstate_memhp_state = {
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
+static const VMStateDescription vmstate_cpuhp_state = {
|
|
||||||
+ .name = "acpi-ged/cpuhp",
|
|
||||||
+ .version_id = 1,
|
|
||||||
+ .minimum_version_id = 1,
|
|
||||||
+ .fields = (VMStateField[]) {
|
|
||||||
+ VMSTATE_CPU_HOTPLUG(cpuhp_state, AcpiGedState),
|
|
||||||
+ VMSTATE_END_OF_LIST()
|
|
||||||
+ }
|
|
||||||
+};
|
|
||||||
+
|
|
||||||
static const VMStateDescription vmstate_ged_state = {
|
|
||||||
.name = "acpi-ged-state",
|
|
||||||
.version_id = 1,
|
|
||||||
@@ -360,6 +378,7 @@ static const VMStateDescription vmstate_acpi_ged = {
|
|
||||||
.subsections = (const VMStateDescription * []) {
|
|
||||||
&vmstate_memhp_state,
|
|
||||||
&vmstate_ghes_state,
|
|
||||||
+ &vmstate_cpuhp_state,
|
|
||||||
NULL
|
|
||||||
}
|
|
||||||
};
|
|
||||||
@@ -370,6 +389,7 @@ static void acpi_ged_initfn(Object *obj)
|
|
||||||
AcpiGedState *s = ACPI_GED(dev);
|
|
||||||
SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
|
|
||||||
GEDState *ged_st = &s->ged_state;
|
|
||||||
+ MachineClass *mc;
|
|
||||||
|
|
||||||
memory_region_init_io(&ged_st->evt, obj, &ged_evt_ops, ged_st,
|
|
||||||
TYPE_ACPI_GED, ACPI_GED_EVT_SEL_LEN);
|
|
||||||
@@ -393,6 +413,21 @@ static void acpi_ged_initfn(Object *obj)
|
|
||||||
memory_region_init_io(&ged_st->regs, obj, &ged_regs_ops, ged_st,
|
|
||||||
TYPE_ACPI_GED "-regs", ACPI_GED_REG_COUNT);
|
|
||||||
sysbus_init_mmio(sbd, &ged_st->regs);
|
|
||||||
+
|
|
||||||
+ mc = MACHINE_GET_CLASS(qdev_get_machine());
|
|
||||||
+ if (!mc->possible_cpu_arch_ids) {
|
|
||||||
+ /*
|
|
||||||
+ * MachineClass should support possible_cpu_arch_ids in
|
|
||||||
+ * cpu_hotplug_hw_init below.
|
|
||||||
+ */
|
|
||||||
+ return;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ memory_region_init(&s->container_cpuhp, OBJECT(dev), "cpuhp container",
|
|
||||||
+ ACPI_CPU_HOTPLUG_REG_LEN);
|
|
||||||
+ sysbus_init_mmio(sbd, &s->container_cpuhp);
|
|
||||||
+ cpu_hotplug_hw_init(&s->container_cpuhp, OBJECT(dev),
|
|
||||||
+ &s->cpuhp_state, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void acpi_ged_class_init(ObjectClass *class, void *data)
|
|
||||||
diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig
|
|
||||||
index 2d37d29f02..006a4b4c4b 100644
|
|
||||||
--- a/hw/arm/Kconfig
|
|
||||||
+++ b/hw/arm/Kconfig
|
|
||||||
@@ -27,6 +27,7 @@ config ARM_VIRT
|
|
||||||
select DIMM
|
|
||||||
select ACPI_HW_REDUCED
|
|
||||||
select ACPI_APEI
|
|
||||||
+ select ACPI_CPU_HOTPLUG
|
|
||||||
|
|
||||||
config CHEETAH
|
|
||||||
bool
|
|
||||||
diff --git a/include/hw/acpi/cpu.h b/include/hw/acpi/cpu.h
|
|
||||||
index a0fdc44bdd..d521025830 100644
|
|
||||||
--- a/include/hw/acpi/cpu.h
|
|
||||||
+++ b/include/hw/acpi/cpu.h
|
|
||||||
@@ -17,6 +17,8 @@
|
|
||||||
#include "hw/acpi/aml-build.h"
|
|
||||||
#include "hw/hotplug.h"
|
|
||||||
|
|
||||||
+#define ACPI_CPU_HOTPLUG_REG_LEN 12
|
|
||||||
+
|
|
||||||
typedef struct AcpiCpuStatus {
|
|
||||||
struct CPUState *cpu;
|
|
||||||
uint64_t arch_id;
|
|
||||||
diff --git a/include/hw/acpi/generic_event_device.h b/include/hw/acpi/generic_event_device.h
|
|
||||||
index d49217c445..6bb2ade385 100644
|
|
||||||
--- a/include/hw/acpi/generic_event_device.h
|
|
||||||
+++ b/include/hw/acpi/generic_event_device.h
|
|
||||||
@@ -63,6 +63,7 @@
|
|
||||||
#include "hw/acpi/memory_hotplug.h"
|
|
||||||
#include "hw/acpi/ghes.h"
|
|
||||||
#include "qom/object.h"
|
|
||||||
+#include "hw/acpi/cpu.h"
|
|
||||||
|
|
||||||
#define ACPI_POWER_BUTTON_DEVICE "PWRB"
|
|
||||||
|
|
||||||
@@ -97,6 +98,7 @@ OBJECT_DECLARE_SIMPLE_TYPE(AcpiGedState, ACPI_GED)
|
|
||||||
#define ACPI_GED_MEM_HOTPLUG_EVT 0x1
|
|
||||||
#define ACPI_GED_PWR_DOWN_EVT 0x2
|
|
||||||
#define ACPI_GED_NVDIMM_HOTPLUG_EVT 0x4
|
|
||||||
+#define ACPI_GED_CPU_HOTPLUG_EVT 0x8
|
|
||||||
|
|
||||||
typedef struct GEDState {
|
|
||||||
MemoryRegion evt;
|
|
||||||
@@ -108,6 +110,8 @@ struct AcpiGedState {
|
|
||||||
SysBusDevice parent_obj;
|
|
||||||
MemHotplugState memhp_state;
|
|
||||||
MemoryRegion container_memhp;
|
|
||||||
+ CPUHotplugState cpuhp_state;
|
|
||||||
+ MemoryRegion container_cpuhp;
|
|
||||||
GEDState ged_state;
|
|
||||||
uint32_t ged_event_bitmap;
|
|
||||||
qemu_irq irq;
|
|
||||||
--
|
|
||||||
2.27.0
|
|
||||||
|
|
||||||
@ -1,84 +0,0 @@
|
|||||||
From 8bd05cdb811e868c54ef28ac558c7efb7cf610b9 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Keqian Zhu <zhukeqian1@huawei.com>
|
|
||||||
Date: Fri, 10 Apr 2020 13:40:44 +0800
|
|
||||||
Subject: [PATCH] acpi/madt: Add pre-sizing capability to MADT GICC struct
|
|
||||||
|
|
||||||
The count of possible CPUs is exposed to guest through the count
|
|
||||||
of MADT GICC struct, so we should pre-sizing MADT GICC too.
|
|
||||||
|
|
||||||
Signed-off-by: Keqian Zhu <zhukeqian1@huawei.com>
|
|
||||||
Signed-off-by: Salil Mehta <salil.mehta@huawei.com>
|
|
||||||
---
|
|
||||||
hw/arm/virt-acpi-build.c | 25 +++++++++++++++++++------
|
|
||||||
1 file changed, 19 insertions(+), 6 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
|
|
||||||
index 7cb320d9f2..a16b54086e 100644
|
|
||||||
--- a/hw/arm/virt-acpi-build.c
|
|
||||||
+++ b/hw/arm/virt-acpi-build.c
|
|
||||||
@@ -787,8 +787,16 @@ void virt_madt_cpu_entry(AcpiDeviceIf *adev, int i,
|
|
||||||
ARMCPU *armcpu = ARM_CPU(qemu_get_cpu(i));
|
|
||||||
uint64_t physical_base_address = 0, gich = 0, gicv = 0;
|
|
||||||
uint32_t vgic_interrupt = vms->virt ? PPI(ARCH_GIC_MAINT_IRQ) : 0;
|
|
||||||
- uint32_t pmu_interrupt = arm_feature(&armcpu->env, ARM_FEATURE_PMU) ?
|
|
||||||
- PPI(VIRTUAL_PMU_IRQ) : 0;
|
|
||||||
+ uint32_t pmu_interrupt, enabled;
|
|
||||||
+ static bool pmu;
|
|
||||||
+
|
|
||||||
+ if (i == 0) {
|
|
||||||
+ pmu = arm_feature(&armcpu->env, ARM_FEATURE_PMU);
|
|
||||||
+ }
|
|
||||||
+ /* FEATURE_PMU should be all enabled or disabled for CPUs */
|
|
||||||
+ assert(!armcpu || arm_feature(&armcpu->env, ARM_FEATURE_PMU) == pmu);
|
|
||||||
+ pmu_interrupt = pmu ? PPI(VIRTUAL_PMU_IRQ) : 0;
|
|
||||||
+ enabled = armcpu || force_enabled ? 1 /* Enabled */ : 0 /* Disabled */;
|
|
||||||
|
|
||||||
if (vms->gic_version == 2) {
|
|
||||||
physical_base_address = memmap[VIRT_GIC_CPU].base;
|
|
||||||
@@ -803,7 +811,7 @@ void virt_madt_cpu_entry(AcpiDeviceIf *adev, int i,
|
|
||||||
build_append_int_noprefix(table_data, i, 4); /* GIC ID */
|
|
||||||
build_append_int_noprefix(table_data, i, 4); /* ACPI Processor UID */
|
|
||||||
/* Flags */
|
|
||||||
- build_append_int_noprefix(table_data, 1, 4); /* Enabled */
|
|
||||||
+ build_append_int_noprefix(table_data, enabled, 4); /* Enabled */
|
|
||||||
/* Parking Protocol Version */
|
|
||||||
build_append_int_noprefix(table_data, 0, 4);
|
|
||||||
/* Performance Interrupt GSIV */
|
|
||||||
@@ -817,7 +825,7 @@ void virt_madt_cpu_entry(AcpiDeviceIf *adev, int i,
|
|
||||||
build_append_int_noprefix(table_data, vgic_interrupt, 4);
|
|
||||||
build_append_int_noprefix(table_data, 0, 8); /* GICR Base Address*/
|
|
||||||
/* MPIDR */
|
|
||||||
- build_append_int_noprefix(table_data, armcpu->mp_affinity, 8);
|
|
||||||
+ build_append_int_noprefix(table_data, possible_cpus->cpus[i].arch_id, 8);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
@@ -825,9 +833,14 @@ build_madt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
VirtMachineClass *vmc = VIRT_MACHINE_GET_CLASS(vms);
|
|
||||||
+ MachineClass *mc = MACHINE_GET_CLASS(vms);
|
|
||||||
+ MachineState *ms = MACHINE(vms);
|
|
||||||
+ const CPUArchIdList *possible_cpus = mc->possible_cpu_arch_ids(ms);
|
|
||||||
const MemMapEntry *memmap = vms->memmap;
|
|
||||||
AcpiTable table = { .sig = "APIC", .rev = 3, .oem_id = vms->oem_id,
|
|
||||||
.oem_table_id = vms->oem_table_id };
|
|
||||||
+ /* The MADT GICC numbers */
|
|
||||||
+ int num_cpu = ms->smp.cpus;
|
|
||||||
|
|
||||||
acpi_table_begin(&table, table_data);
|
|
||||||
/* Local Interrupt Controller Address */
|
|
||||||
@@ -846,8 +859,8 @@ build_madt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
|
|
||||||
build_append_int_noprefix(table_data, vms->gic_version, 1);
|
|
||||||
build_append_int_noprefix(table_data, 0, 3); /* Reserved */
|
|
||||||
|
|
||||||
- for (i = 0; i < MACHINE(vms)->smp.cpus; i++) {
|
|
||||||
- virt_madt_cpu_entry(NULL, i, NULL, table_data, false);
|
|
||||||
+ for (i = 0; i < num_cpu; i++) {
|
|
||||||
+ virt_madt_cpu_entry(NULL, i, possible_cpus, table_data, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (vms->gic_version == 3) {
|
|
||||||
--
|
|
||||||
2.27.0
|
|
||||||
|
|
||||||
@ -1,136 +0,0 @@
|
|||||||
From 4f50ed900713acc14c971c07165fa83670d3f2b8 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Keqian Zhu <zhukeqian1@huawei.com>
|
|
||||||
Date: Mon, 13 Jan 2020 19:02:20 +0800
|
|
||||||
Subject: [PATCH] acpi/madt: Factor out the building of MADT GICC struct
|
|
||||||
|
|
||||||
To realize CPU hotplug, the cpus aml within ACPI DSDT should contain
|
|
||||||
_MAT mathod, which is equal to the GICC struct in ACPI MADT. Factor
|
|
||||||
out the GICC building code from ACPI MADT and reuse it in build_cpus_aml.
|
|
||||||
|
|
||||||
Signed-off-by: Keqian Zhu <zhukeqian1@huawei.com>
|
|
||||||
Signed-off-by: Salil Mehta <salil.mehta@huawei.com>
|
|
||||||
---
|
|
||||||
hw/arm/virt-acpi-build.c | 77 ++++++++++++++++++++++------------------
|
|
||||||
include/hw/arm/virt.h | 4 +++
|
|
||||||
2 files changed, 47 insertions(+), 34 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
|
|
||||||
index 1ca705654b..64b1ed8672 100644
|
|
||||||
--- a/hw/arm/virt-acpi-build.c
|
|
||||||
+++ b/hw/arm/virt-acpi-build.c
|
|
||||||
@@ -771,6 +771,48 @@ static void build_append_gicr(GArray *table_data, uint64_t base, uint32_t size)
|
|
||||||
build_append_int_noprefix(table_data, size, 4); /* Discovery Range Length */
|
|
||||||
}
|
|
||||||
|
|
||||||
+void virt_madt_cpu_entry(AcpiDeviceIf *adev, int i,
|
|
||||||
+ const CPUArchIdList *possible_cpus, GArray *table_data,
|
|
||||||
+ bool force_enabled)
|
|
||||||
+{
|
|
||||||
+ VirtMachineState *vms = VIRT_MACHINE(qdev_get_machine());
|
|
||||||
+ const MemMapEntry *memmap = vms->memmap;
|
|
||||||
+ ARMCPU *armcpu = ARM_CPU(qemu_get_cpu(i));
|
|
||||||
+ uint64_t physical_base_address = 0, gich = 0, gicv = 0;
|
|
||||||
+ uint32_t vgic_interrupt = vms->virt ? PPI(ARCH_GIC_MAINT_IRQ) : 0;
|
|
||||||
+ uint32_t pmu_interrupt = arm_feature(&armcpu->env, ARM_FEATURE_PMU) ?
|
|
||||||
+ PPI(VIRTUAL_PMU_IRQ) : 0;
|
|
||||||
+
|
|
||||||
+ if (vms->gic_version == 2) {
|
|
||||||
+ physical_base_address = memmap[VIRT_GIC_CPU].base;
|
|
||||||
+ gicv = memmap[VIRT_GIC_VCPU].base;
|
|
||||||
+ gich = memmap[VIRT_GIC_HYP].base;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ /* 5.2.12.14 GIC Structure */
|
|
||||||
+ build_append_int_noprefix(table_data, 0xB, 1); /* Type */
|
|
||||||
+ build_append_int_noprefix(table_data, 76, 1); /* Length */
|
|
||||||
+ build_append_int_noprefix(table_data, 0, 2); /* Reserved */
|
|
||||||
+ build_append_int_noprefix(table_data, i, 4); /* GIC ID */
|
|
||||||
+ build_append_int_noprefix(table_data, i, 4); /* ACPI Processor UID */
|
|
||||||
+ /* Flags */
|
|
||||||
+ build_append_int_noprefix(table_data, 1, 4); /* Enabled */
|
|
||||||
+ /* Parking Protocol Version */
|
|
||||||
+ build_append_int_noprefix(table_data, 0, 4);
|
|
||||||
+ /* Performance Interrupt GSIV */
|
|
||||||
+ build_append_int_noprefix(table_data, pmu_interrupt, 4);
|
|
||||||
+ build_append_int_noprefix(table_data, 0, 8); /* Parked Address */
|
|
||||||
+ /* Physical Base Address */
|
|
||||||
+ build_append_int_noprefix(table_data, physical_base_address, 8);
|
|
||||||
+ build_append_int_noprefix(table_data, gicv, 8); /* GICV */
|
|
||||||
+ build_append_int_noprefix(table_data, gich, 8); /* GICH */
|
|
||||||
+ /* VGIC Maintenance interrupt */
|
|
||||||
+ build_append_int_noprefix(table_data, vgic_interrupt, 4);
|
|
||||||
+ build_append_int_noprefix(table_data, 0, 8); /* GICR Base Address*/
|
|
||||||
+ /* MPIDR */
|
|
||||||
+ build_append_int_noprefix(table_data, armcpu->mp_affinity, 8);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
static void
|
|
||||||
build_madt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
|
|
||||||
{
|
|
||||||
@@ -798,40 +840,7 @@ build_madt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
|
|
||||||
build_append_int_noprefix(table_data, 0, 3); /* Reserved */
|
|
||||||
|
|
||||||
for (i = 0; i < MACHINE(vms)->smp.cpus; i++) {
|
|
||||||
- ARMCPU *armcpu = ARM_CPU(qemu_get_cpu(i));
|
|
||||||
- uint64_t physical_base_address = 0, gich = 0, gicv = 0;
|
|
||||||
- uint32_t vgic_interrupt = vms->virt ? PPI(ARCH_GIC_MAINT_IRQ) : 0;
|
|
||||||
- uint32_t pmu_interrupt = arm_feature(&armcpu->env, ARM_FEATURE_PMU) ?
|
|
||||||
- PPI(VIRTUAL_PMU_IRQ) : 0;
|
|
||||||
-
|
|
||||||
- if (vms->gic_version == 2) {
|
|
||||||
- physical_base_address = memmap[VIRT_GIC_CPU].base;
|
|
||||||
- gicv = memmap[VIRT_GIC_VCPU].base;
|
|
||||||
- gich = memmap[VIRT_GIC_HYP].base;
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
- /* 5.2.12.14 GIC Structure */
|
|
||||||
- build_append_int_noprefix(table_data, 0xB, 1); /* Type */
|
|
||||||
- build_append_int_noprefix(table_data, 76, 1); /* Length */
|
|
||||||
- build_append_int_noprefix(table_data, 0, 2); /* Reserved */
|
|
||||||
- build_append_int_noprefix(table_data, i, 4); /* GIC ID */
|
|
||||||
- build_append_int_noprefix(table_data, i, 4); /* ACPI Processor UID */
|
|
||||||
- /* Flags */
|
|
||||||
- build_append_int_noprefix(table_data, 1, 4); /* Enabled */
|
|
||||||
- /* Parking Protocol Version */
|
|
||||||
- build_append_int_noprefix(table_data, 0, 4);
|
|
||||||
- /* Performance Interrupt GSIV */
|
|
||||||
- build_append_int_noprefix(table_data, pmu_interrupt, 4);
|
|
||||||
- build_append_int_noprefix(table_data, 0, 8); /* Parked Address */
|
|
||||||
- /* Physical Base Address */
|
|
||||||
- build_append_int_noprefix(table_data, physical_base_address, 8);
|
|
||||||
- build_append_int_noprefix(table_data, gicv, 8); /* GICV */
|
|
||||||
- build_append_int_noprefix(table_data, gich, 8); /* GICH */
|
|
||||||
- /* VGIC Maintenance interrupt */
|
|
||||||
- build_append_int_noprefix(table_data, vgic_interrupt, 4);
|
|
||||||
- build_append_int_noprefix(table_data, 0, 8); /* GICR Base Address*/
|
|
||||||
- /* MPIDR */
|
|
||||||
- build_append_int_noprefix(table_data, armcpu->mp_affinity, 8);
|
|
||||||
+ virt_madt_cpu_entry(NULL, i, NULL, table_data, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (vms->gic_version == 3) {
|
|
||||||
diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h
|
|
||||||
index a4356cf736..36639e8d3e 100644
|
|
||||||
--- a/include/hw/arm/virt.h
|
|
||||||
+++ b/include/hw/arm/virt.h
|
|
||||||
@@ -38,6 +38,7 @@
|
|
||||||
#include "sysemu/kvm.h"
|
|
||||||
#include "hw/intc/arm_gicv3_common.h"
|
|
||||||
#include "qom/object.h"
|
|
||||||
+#include "hw/acpi/acpi_dev_interface.h"
|
|
||||||
|
|
||||||
#define NUM_GICV2M_SPIS 64
|
|
||||||
#define NUM_VIRTIO_TRANSPORTS 32
|
|
||||||
@@ -181,6 +182,9 @@ OBJECT_DECLARE_TYPE(VirtMachineState, VirtMachineClass, VIRT_MACHINE)
|
|
||||||
|
|
||||||
void virt_acpi_setup(VirtMachineState *vms);
|
|
||||||
bool virt_is_acpi_enabled(VirtMachineState *vms);
|
|
||||||
+void virt_madt_cpu_entry(AcpiDeviceIf *adev, int uid,
|
|
||||||
+ const CPUArchIdList *cpu_list, GArray *entry,
|
|
||||||
+ bool force_enabled);
|
|
||||||
|
|
||||||
/* Return the number of used redistributor regions */
|
|
||||||
static inline int virt_gicv3_redist_region_count(VirtMachineState *vms)
|
|
||||||
--
|
|
||||||
2.27.0
|
|
||||||
|
|
||||||
@ -1,100 +0,0 @@
|
|||||||
From 69564ae0e54345391ceceadb6cde9a09db01c2d9 Mon Sep 17 00:00:00 2001
|
|
||||||
From: saarloos <9090-90-90-9090@163.com>
|
|
||||||
Date: Mon, 23 May 2022 20:59:51 +0800
|
|
||||||
Subject: [PATCH] arm/acpi: Fix when make qemu-system-aarch64 at x86_64 host
|
|
||||||
bios_tables_test fail reason: __aarch64__ macro let build_pptt at x86_64 and
|
|
||||||
aarch64 host build different function that let bios_tables_test fail.
|
|
||||||
|
|
||||||
Signed-off-by: Yangzi Zhang <zhangziyang1@huawei.com>
|
|
||||||
---
|
|
||||||
hw/acpi/aml-build.c | 5 +----
|
|
||||||
hw/arm/virt-acpi-build.c | 2 +-
|
|
||||||
include/hw/acpi/aml-build.h | 7 +++----
|
|
||||||
3 files changed, 5 insertions(+), 9 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c
|
|
||||||
index c4edaafa4a..39b8d807c0 100644
|
|
||||||
--- a/hw/acpi/aml-build.c
|
|
||||||
+++ b/hw/acpi/aml-build.c
|
|
||||||
@@ -2016,7 +2016,6 @@ static void build_processor_hierarchy_node(GArray *tbl, uint32_t flags,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
-#ifdef __aarch64__
|
|
||||||
/*
|
|
||||||
* ACPI spec, Revision 6.3
|
|
||||||
* 5.2.29.2 Cache Type Structure (Type 1)
|
|
||||||
@@ -2072,7 +2071,7 @@ static void build_cache_hierarchy_node(GArray *tbl, uint32_t next_level,
|
|
||||||
* ACPI spec, Revision 6.3
|
|
||||||
* 5.2.29 Processor Properties Topology Table (PPTT)
|
|
||||||
*/
|
|
||||||
-void build_pptt(GArray *table_data, BIOSLinker *linker, MachineState *ms,
|
|
||||||
+void build_pptt_arm(GArray *table_data, BIOSLinker *linker, MachineState *ms,
|
|
||||||
const char *oem_id, const char *oem_table_id)
|
|
||||||
{
|
|
||||||
MachineClass *mc = MACHINE_GET_CLASS(ms);
|
|
||||||
@@ -2172,7 +2171,6 @@ void build_pptt(GArray *table_data, BIOSLinker *linker, MachineState *ms,
|
|
||||||
acpi_table_end(linker, &table);
|
|
||||||
}
|
|
||||||
|
|
||||||
-#else
|
|
||||||
/*
|
|
||||||
* ACPI spec, Revision 6.3
|
|
||||||
* 5.2.29 Processor Properties Topology Table (PPTT)
|
|
||||||
@@ -2263,7 +2261,6 @@ void build_pptt(GArray *table_data, BIOSLinker *linker, MachineState *ms,
|
|
||||||
g_queue_free(list);
|
|
||||||
acpi_table_end(linker, &table);
|
|
||||||
}
|
|
||||||
-#endif
|
|
||||||
|
|
||||||
/* build rev1/rev3/rev5.1 FADT */
|
|
||||||
void build_fadt(GArray *tbl, BIOSLinker *linker, const AcpiFadtData *f,
|
|
||||||
diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
|
|
||||||
index 1101161d70..89cecdd8e6 100644
|
|
||||||
--- a/hw/arm/virt-acpi-build.c
|
|
||||||
+++ b/hw/arm/virt-acpi-build.c
|
|
||||||
@@ -1070,7 +1070,7 @@ void virt_acpi_build(VirtMachineState *vms, AcpiBuildTables *tables)
|
|
||||||
|
|
||||||
if (!vmc->no_cpu_topology) {
|
|
||||||
acpi_add_table(table_offsets, tables_blob);
|
|
||||||
- build_pptt(tables_blob, tables->linker, ms,
|
|
||||||
+ build_pptt_arm(tables_blob, tables->linker, ms,
|
|
||||||
vms->oem_id, vms->oem_table_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
diff --git a/include/hw/acpi/aml-build.h b/include/hw/acpi/aml-build.h
|
|
||||||
index 2e00d2e208..5e9b72c024 100644
|
|
||||||
--- a/include/hw/acpi/aml-build.h
|
|
||||||
+++ b/include/hw/acpi/aml-build.h
|
|
||||||
@@ -221,9 +221,7 @@ struct AcpiBuildTables {
|
|
||||||
BIOSLinker *linker;
|
|
||||||
} AcpiBuildTables;
|
|
||||||
|
|
||||||
-#ifdef __aarch64__
|
|
||||||
/* Definitions of the hardcoded cache info*/
|
|
||||||
-
|
|
||||||
typedef enum {
|
|
||||||
ARM_L1D_CACHE,
|
|
||||||
ARM_L1I_CACHE,
|
|
||||||
@@ -266,8 +264,6 @@ struct offset_status {
|
|
||||||
uint32_t l1i_offset;
|
|
||||||
};
|
|
||||||
|
|
||||||
-#endif
|
|
||||||
-
|
|
||||||
typedef
|
|
||||||
struct CrsRangeEntry {
|
|
||||||
uint64_t base;
|
|
||||||
@@ -542,6 +538,9 @@ void build_slit(GArray *table_data, BIOSLinker *linker, MachineState *ms,
|
|
||||||
void build_pptt(GArray *table_data, BIOSLinker *linker, MachineState *ms,
|
|
||||||
const char *oem_id, const char *oem_table_id);
|
|
||||||
|
|
||||||
+void build_pptt_arm(GArray *table_data, BIOSLinker *linker, MachineState *ms,
|
|
||||||
+ const char *oem_id, const char *oem_table_id);
|
|
||||||
+
|
|
||||||
void build_fadt(GArray *tbl, BIOSLinker *linker, const AcpiFadtData *f,
|
|
||||||
const char *oem_id, const char *oem_table_id);
|
|
||||||
|
|
||||||
--
|
|
||||||
2.35.1.windows.2
|
|
||||||
|
|
||||||
@ -1,121 +0,0 @@
|
|||||||
From 6c92ab0387c2af443142a0cc47134389711a14dc Mon Sep 17 00:00:00 2001
|
|
||||||
From: Igor Mammedov <imammedo@redhat.com>
|
|
||||||
Date: Tue, 1 Mar 2022 10:11:59 -0500
|
|
||||||
Subject: [PATCH 5/6] acpi: pcihp: pcie: set power on cap on parent slot
|
|
||||||
|
|
||||||
on creation a PCIDevice has power turned on at the end of pci_qdev_realize()
|
|
||||||
however later on if PCIe slot isn't populated with any children
|
|
||||||
it's power is turned off. It's fine if native hotplug is used
|
|
||||||
as plug callback will power slot on among other things.
|
|
||||||
However when ACPI hotplug is enabled it replaces native PCIe plug
|
|
||||||
callbacks with ACPI specific ones (acpi_pcihp_device_*plug_cb) and
|
|
||||||
as result slot stays powered off. It works fine as ACPI hotplug
|
|
||||||
on guest side takes care of enumerating/initializing hotplugged
|
|
||||||
device. But when later guest is migrated, call chain introduced by]
|
|
||||||
commit d5daff7d312 (pcie: implement slot power control for pcie root ports)
|
|
||||||
|
|
||||||
pcie_cap_slot_post_load()
|
|
||||||
-> pcie_cap_update_power()
|
|
||||||
-> pcie_set_power_device()
|
|
||||||
-> pci_set_power()
|
|
||||||
-> pci_update_mappings()
|
|
||||||
|
|
||||||
will disable earlier initialized BARs for the hotplugged device
|
|
||||||
in powered off slot due to commit 23786d13441 (pci: implement power state)
|
|
||||||
which disables BARs if power is off.
|
|
||||||
|
|
||||||
Fix it by setting PCI_EXP_SLTCTL_PCC to PCI_EXP_SLTCTL_PWR_ON
|
|
||||||
on slot (root port/downstream port) at the time a device
|
|
||||||
hotplugged into it. As result PCI_EXP_SLTCTL_PWR_ON is migrated
|
|
||||||
to target and above call chain keeps device plugged into it
|
|
||||||
powered on.
|
|
||||||
|
|
||||||
Fixes: d5daff7d312 ("pcie: implement slot power control for pcie root ports")
|
|
||||||
Fixes: 23786d13441 ("pci: implement power state")
|
|
||||||
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2053584
|
|
||||||
Suggested-by: "Michael S. Tsirkin" <mst@redhat.com>
|
|
||||||
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
|
|
||||||
Message-Id: <20220301151200.3507298-3-imammedo@redhat.com>
|
|
||||||
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
|
|
||||||
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
|
|
||||||
Signed-off-by: wanbo <wanbo13@huawei.com>
|
|
||||||
---
|
|
||||||
hw/acpi/pcihp.c | 12 +++++++++++-
|
|
||||||
hw/pci/pcie.c | 11 +++++++++++
|
|
||||||
include/hw/pci/pcie.h | 1 +
|
|
||||||
3 files changed, 23 insertions(+), 1 deletion(-)
|
|
||||||
|
|
||||||
diff --git a/hw/acpi/pcihp.c b/hw/acpi/pcihp.c
|
|
||||||
index a5e182dd3a..be0e846b34 100644
|
|
||||||
--- a/hw/acpi/pcihp.c
|
|
||||||
+++ b/hw/acpi/pcihp.c
|
|
||||||
@@ -32,6 +32,7 @@
|
|
||||||
#include "hw/pci/pci_bridge.h"
|
|
||||||
#include "hw/pci/pci_host.h"
|
|
||||||
#include "hw/pci/pcie_port.h"
|
|
||||||
+#include "hw/pci-bridge/xio3130_downstream.h"
|
|
||||||
#include "hw/i386/acpi-build.h"
|
|
||||||
#include "hw/acpi/acpi.h"
|
|
||||||
#include "hw/pci/pci_bus.h"
|
|
||||||
@@ -341,6 +342,8 @@ void acpi_pcihp_device_plug_cb(HotplugHandler *hotplug_dev, AcpiPciHpState *s,
|
|
||||||
{
|
|
||||||
PCIDevice *pdev = PCI_DEVICE(dev);
|
|
||||||
int slot = PCI_SLOT(pdev->devfn);
|
|
||||||
+ PCIDevice *bridge;
|
|
||||||
+ PCIBus *bus;
|
|
||||||
int bsel;
|
|
||||||
|
|
||||||
/* Don't send event when device is enabled during qemu machine creation:
|
|
||||||
@@ -370,7 +373,14 @@ void acpi_pcihp_device_plug_cb(HotplugHandler *hotplug_dev, AcpiPciHpState *s,
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
- bsel = acpi_pcihp_get_bsel(pci_get_bus(pdev));
|
|
||||||
+ bus = pci_get_bus(pdev);
|
|
||||||
+ bridge = pci_bridge_get_device(bus);
|
|
||||||
+ if (object_dynamic_cast(OBJECT(bridge), TYPE_PCIE_ROOT_PORT) ||
|
|
||||||
+ object_dynamic_cast(OBJECT(bridge), TYPE_XIO3130_DOWNSTREAM)) {
|
|
||||||
+ pcie_cap_slot_enable_power(bridge);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ bsel = acpi_pcihp_get_bsel(bus);
|
|
||||||
g_assert(bsel >= 0);
|
|
||||||
s->acpi_pcihp_pci_status[bsel].up |= (1U << slot);
|
|
||||||
acpi_send_event(DEVICE(hotplug_dev), ACPI_PCI_HOTPLUG_STATUS);
|
|
||||||
diff --git a/hw/pci/pcie.c b/hw/pci/pcie.c
|
|
||||||
index 30c09ed943..a2d1ae6021 100644
|
|
||||||
--- a/hw/pci/pcie.c
|
|
||||||
+++ b/hw/pci/pcie.c
|
|
||||||
@@ -365,6 +365,17 @@ static void hotplug_event_clear(PCIDevice *dev)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
+void pcie_cap_slot_enable_power(PCIDevice *dev)
|
|
||||||
+{
|
|
||||||
+ uint8_t *exp_cap = dev->config + dev->exp.exp_cap;
|
|
||||||
+ uint32_t sltcap = pci_get_long(exp_cap + PCI_EXP_SLTCAP);
|
|
||||||
+
|
|
||||||
+ if (sltcap & PCI_EXP_SLTCAP_PCP) {
|
|
||||||
+ pci_set_word_by_mask(exp_cap + PCI_EXP_SLTCTL,
|
|
||||||
+ PCI_EXP_SLTCTL_PCC, PCI_EXP_SLTCTL_PWR_ON);
|
|
||||||
+ }
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
static void pcie_set_power_device(PCIBus *bus, PCIDevice *dev, void *opaque)
|
|
||||||
{
|
|
||||||
bool *power = opaque;
|
|
||||||
diff --git a/include/hw/pci/pcie.h b/include/hw/pci/pcie.h
|
|
||||||
index 6063bee0ec..c27368d077 100644
|
|
||||||
--- a/include/hw/pci/pcie.h
|
|
||||||
+++ b/include/hw/pci/pcie.h
|
|
||||||
@@ -112,6 +112,7 @@ void pcie_cap_slot_write_config(PCIDevice *dev,
|
|
||||||
uint32_t addr, uint32_t val, int len);
|
|
||||||
int pcie_cap_slot_post_load(void *opaque, int version_id);
|
|
||||||
void pcie_cap_slot_push_attention_button(PCIDevice *dev);
|
|
||||||
+void pcie_cap_slot_enable_power(PCIDevice *dev);
|
|
||||||
|
|
||||||
void pcie_cap_root_init(PCIDevice *dev);
|
|
||||||
void pcie_cap_root_reset(PCIDevice *dev);
|
|
||||||
--
|
|
||||||
2.27.0
|
|
||||||
|
|
||||||
@ -1,41 +0,0 @@
|
|||||||
From 1205bf5738346fe9f217f5db08500b12b812aafa Mon Sep 17 00:00:00 2001
|
|
||||||
From: "Michael S. Tsirkin" <mst@redhat.com>
|
|
||||||
Date: Tue, 21 Dec 2021 09:45:44 -0500
|
|
||||||
Subject: [PATCH 1/2] acpi: validate hotplug selector on access
|
|
||||||
MIME-Version: 1.0
|
|
||||||
Content-Type: text/plain; charset=UTF-8
|
|
||||||
Content-Transfer-Encoding: 8bit
|
|
||||||
|
|
||||||
When bus is looked up on a pci write, we didn't
|
|
||||||
validate that the lookup succeeded.
|
|
||||||
Fuzzers thus can trigger QEMU crash by dereferencing the NULL
|
|
||||||
bus pointer.
|
|
||||||
|
|
||||||
Fixes: b32bd763a1 ("pci: introduce acpi-index property for PCI device")
|
|
||||||
Fixes: CVE-2021-4158
|
|
||||||
Cc: "Igor Mammedov" <imammedo@redhat.com>
|
|
||||||
Fixes: https://gitlab.com/qemu-project/qemu/-/issues/770
|
|
||||||
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
|
|
||||||
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
|
|
||||||
Reviewed-by: Ani Sinha <ani@anisinha.ca>
|
|
||||||
---
|
|
||||||
hw/acpi/pcihp.c | 3 +++
|
|
||||||
1 file changed, 3 insertions(+)
|
|
||||||
|
|
||||||
diff --git a/hw/acpi/pcihp.c b/hw/acpi/pcihp.c
|
|
||||||
index 30405b5113..a5e182dd3a 100644
|
|
||||||
--- a/hw/acpi/pcihp.c
|
|
||||||
+++ b/hw/acpi/pcihp.c
|
|
||||||
@@ -491,6 +491,9 @@ static void pci_write(void *opaque, hwaddr addr, uint64_t data,
|
|
||||||
}
|
|
||||||
|
|
||||||
bus = acpi_pcihp_find_hotplug_bus(s, s->hotplug_select);
|
|
||||||
+ if (!bus) {
|
|
||||||
+ break;
|
|
||||||
+ }
|
|
||||||
QTAILQ_FOREACH_SAFE(kid, &bus->qbus.children, sibling, next) {
|
|
||||||
Object *o = OBJECT(kid->child);
|
|
||||||
PCIDevice *dev = PCI_DEVICE(o);
|
|
||||||
--
|
|
||||||
2.27.0
|
|
||||||
|
|
||||||
@ -1,74 +0,0 @@
|
|||||||
From ec35c96006851a956a7e401f29af0ffe137c4bb9 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Jiadong Zeng <zengjiadong@phytium.com.cn>
|
|
||||||
Date: Tue, 8 Feb 2022 22:56:37 +0800
|
|
||||||
Subject: [PATCH] add Phytium's CPU models: FT-2000+ and Tengyun-S2500.
|
|
||||||
|
|
||||||
Signed-off-by: Jiadong Zeng <zengjiadong@phytium.com.cn>
|
|
||||||
Signed-off-by: Mingwang Li <limingwang@huawei.com>
|
|
||||||
---
|
|
||||||
hw/arm/virt.c | 2 ++
|
|
||||||
target/arm/cpu64.c | 28 ++++++++++++++++++++++++++++
|
|
||||||
2 files changed, 30 insertions(+)
|
|
||||||
|
|
||||||
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
|
|
||||||
index a4a35584e9..3c972fdab0 100644
|
|
||||||
--- a/hw/arm/virt.c
|
|
||||||
+++ b/hw/arm/virt.c
|
|
||||||
@@ -202,6 +202,8 @@ static const char *valid_cpus[] = {
|
|
||||||
ARM_CPU_TYPE_NAME("cortex-a57"),
|
|
||||||
ARM_CPU_TYPE_NAME("cortex-a72"),
|
|
||||||
ARM_CPU_TYPE_NAME("Kunpeng-920"),
|
|
||||||
+ ARM_CPU_TYPE_NAME("FT-2000+"),
|
|
||||||
+ ARM_CPU_TYPE_NAME("Tengyun-S2500"),
|
|
||||||
ARM_CPU_TYPE_NAME("a64fx"),
|
|
||||||
ARM_CPU_TYPE_NAME("host"),
|
|
||||||
ARM_CPU_TYPE_NAME("max"),
|
|
||||||
diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c
|
|
||||||
index 556b6f3691..08d886de7b 100644
|
|
||||||
--- a/target/arm/cpu64.c
|
|
||||||
+++ b/target/arm/cpu64.c
|
|
||||||
@@ -676,6 +676,32 @@ static Property arm_cpu_pauth_property =
|
|
||||||
static Property arm_cpu_pauth_impdef_property =
|
|
||||||
DEFINE_PROP_BOOL("pauth-impdef", ARMCPU, prop_pauth_impdef, false);
|
|
||||||
|
|
||||||
+static void aarch64_max_ft2000plus_initfn(Object *obj)
|
|
||||||
+{
|
|
||||||
+ ARMCPU *cpu = ARM_CPU(obj);
|
|
||||||
+
|
|
||||||
+ if (kvm_enabled()) {
|
|
||||||
+ kvm_arm_set_cpu_features_from_host(cpu);
|
|
||||||
+ kvm_arm_add_vcpu_properties(obj);
|
|
||||||
+ } else {
|
|
||||||
+ aarch64_a72_initfn(obj);
|
|
||||||
+ cpu->midr = 0x70186622;
|
|
||||||
+ }
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+static void aarch64_max_tengyun_s2500_initfn(Object *obj)
|
|
||||||
+{
|
|
||||||
+ ARMCPU *cpu = ARM_CPU(obj);
|
|
||||||
+
|
|
||||||
+ if (kvm_enabled()) {
|
|
||||||
+ kvm_arm_set_cpu_features_from_host(cpu);
|
|
||||||
+ kvm_arm_add_vcpu_properties(obj);
|
|
||||||
+ } else {
|
|
||||||
+ aarch64_a72_initfn(obj);
|
|
||||||
+ cpu->midr = 0x70186632;
|
|
||||||
+ }
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
/* -cpu max: if KVM is enabled, like -cpu host (best possible with this host);
|
|
||||||
* otherwise, a CPU with as many features enabled as our emulation supports.
|
|
||||||
* The version of '-cpu max' for qemu-system-arm is defined in cpu.c;
|
|
||||||
@@ -914,6 +940,8 @@ static const ARMCPUInfo aarch64_cpus[] = {
|
|
||||||
{ .name = "cortex-a53", .initfn = aarch64_a53_initfn },
|
|
||||||
{ .name = "cortex-a72", .initfn = aarch64_a72_initfn },
|
|
||||||
{ .name = "Kunpeng-920", .initfn = aarch64_kunpeng_920_initfn},
|
|
||||||
+ { .name = "FT-2000+", .initfn = aarch64_max_ft2000plus_initfn },
|
|
||||||
+ { .name = "Tengyun-S2500", .initfn = aarch64_max_tengyun_s2500_initfn },
|
|
||||||
{ .name = "a64fx", .initfn = aarch64_a64fx_initfn },
|
|
||||||
{ .name = "max", .initfn = aarch64_max_initfn },
|
|
||||||
};
|
|
||||||
--
|
|
||||||
2.27.0
|
|
||||||
|
|
||||||
@ -1,56 +0,0 @@
|
|||||||
From f900bc66931458b824274027417b6375610c8d9a Mon Sep 17 00:00:00 2001
|
|
||||||
From: Haiyue Wang <haiyue.wang@intel.com>
|
|
||||||
Date: Tue, 22 Feb 2022 00:24:01 +0800
|
|
||||||
Subject: [PATCH] aio-posix: fix build failure io_uring 2.2
|
|
||||||
MIME-Version: 1.0
|
|
||||||
Content-Type: text/plain; charset=UTF-8
|
|
||||||
Content-Transfer-Encoding: 8bit
|
|
||||||
|
|
||||||
The io_uring fixed "Don't truncate addr fields to 32-bit on 32-bit":
|
|
||||||
https://git.kernel.dk/cgit/liburing/commit/?id=d84c29b19ed0b130000619cff40141bb1fc3615b
|
|
||||||
|
|
||||||
This leads to build failure:
|
|
||||||
../util/fdmon-io_uring.c: In function ‘add_poll_remove_sqe’:
|
|
||||||
../util/fdmon-io_uring.c:182:36: error: passing argument 2 of ‘io_uring_prep_poll_remove’ makes integer from pointer without a cast [-Werror=int-conversion]
|
|
||||||
182 | io_uring_prep_poll_remove(sqe, node);
|
|
||||||
| ^~~~
|
|
||||||
| |
|
|
||||||
| AioHandler *
|
|
||||||
In file included from /root/io/qemu/include/block/aio.h:18,
|
|
||||||
from ../util/aio-posix.h:20,
|
|
||||||
from ../util/fdmon-io_uring.c:49:
|
|
||||||
/usr/include/liburing.h:415:17: note: expected ‘__u64’ {aka ‘long long unsigned int’} but argument is of type ‘AioHandler *’
|
|
||||||
415 | __u64 user_data)
|
|
||||||
| ~~~~~~^~~~~~~~~
|
|
||||||
cc1: all warnings being treated as errors
|
|
||||||
|
|
||||||
Use LIBURING_HAVE_DATA64 to check whether the io_uring supports 64-bit
|
|
||||||
variants of the get/set userdata, to convert the paramter to the right
|
|
||||||
data type.
|
|
||||||
|
|
||||||
Signed-off-by: Haiyue Wang <haiyue.wang@intel.com>
|
|
||||||
Message-Id: <20220221162401.45415-1-haiyue.wang@intel.com>
|
|
||||||
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
||||||
---
|
|
||||||
util/fdmon-io_uring.c | 4 ++++
|
|
||||||
1 file changed, 4 insertions(+)
|
|
||||||
|
|
||||||
diff --git a/util/fdmon-io_uring.c b/util/fdmon-io_uring.c
|
|
||||||
index 1461dfa407..ab43052dd7 100644
|
|
||||||
--- a/util/fdmon-io_uring.c
|
|
||||||
+++ b/util/fdmon-io_uring.c
|
|
||||||
@@ -179,7 +179,11 @@ static void add_poll_remove_sqe(AioContext *ctx, AioHandler *node)
|
|
||||||
{
|
|
||||||
struct io_uring_sqe *sqe = get_sqe(ctx);
|
|
||||||
|
|
||||||
+#ifdef LIBURING_HAVE_DATA64
|
|
||||||
+ io_uring_prep_poll_remove(sqe, (__u64)(uintptr_t)node);
|
|
||||||
+#else
|
|
||||||
io_uring_prep_poll_remove(sqe, node);
|
|
||||||
+#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Add a timeout that self-cancels when another cqe becomes ready */
|
|
||||||
--
|
|
||||||
2.41.0.windows.1
|
|
||||||
|
|
||||||
@ -1,82 +0,0 @@
|
|||||||
From 4ab8e11adf5878d1f298a682b37d7de4632a3a8b Mon Sep 17 00:00:00 2001
|
|
||||||
From: wangmeiyang <wangmeiyang@xfusion.com>
|
|
||||||
Date: Fri, 28 Apr 2023 15:22:07 +0800
|
|
||||||
Subject: [PATCH] aio-posix: fix race between epoll upgrade and
|
|
||||||
aio_set_fd_handler()
|
|
||||||
|
|
||||||
If another thread calls aio_set_fd_handler() while the IOThread event
|
|
||||||
loop is upgrading from ppoll(2) to epoll(7) then we might miss new
|
|
||||||
AioHandlers. The epollfd will not monitor the new AioHandler's fd,
|
|
||||||
resulting in hangs.
|
|
||||||
|
|
||||||
Take the AioHandler list lock while upgrading to epoll. This prevents
|
|
||||||
AioHandlers from changing while epoll is being set up. If we cannot lock
|
|
||||||
because we're in a nested event loop, then don't upgrade to epoll (it
|
|
||||||
will happen next time we're not in a nested call).
|
|
||||||
|
|
||||||
The downside to taking the lock is that the aio_set_fd_handler() thread
|
|
||||||
has to wait until the epoll upgrade is finished, which involves many
|
|
||||||
epoll_ctl(2) system calls. However, this scenario is rare and I couldn't
|
|
||||||
think of another solution that is still simple.
|
|
||||||
|
|
||||||
origin commit: https://gitlab.com/qemu-project/qemu/-/commit/e62da98527fa35fe5f532cded01a33edf9fbe7b2
|
|
||||||
Signed-off-by: Meiyang Wang <wangmeiyang@xfusion.com>
|
|
||||||
Reported-by: Qing Wang <qinwang@redhat.com>
|
|
||||||
Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=2090998
|
|
||||||
Cc: Paolo Bonzini <pbonzini@redhat.com>
|
|
||||||
Cc: Fam Zheng <fam@euphon.net>
|
|
||||||
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
||||||
Message-Id: <20230323144859.1338495-1-stefanha@redhat.com>
|
|
||||||
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
|
|
||||||
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
||||||
---
|
|
||||||
util/fdmon-epoll.c | 25 ++++++++++++++++++-------
|
|
||||||
1 file changed, 18 insertions(+), 7 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/util/fdmon-epoll.c b/util/fdmon-epoll.c
|
|
||||||
index e11a8a022e..1683aa1105 100644
|
|
||||||
--- a/util/fdmon-epoll.c
|
|
||||||
+++ b/util/fdmon-epoll.c
|
|
||||||
@@ -127,6 +127,8 @@ static bool fdmon_epoll_try_enable(AioContext *ctx)
|
|
||||||
|
|
||||||
bool fdmon_epoll_try_upgrade(AioContext *ctx, unsigned npfd)
|
|
||||||
{
|
|
||||||
+ bool ok;
|
|
||||||
+
|
|
||||||
if (ctx->epollfd < 0) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
@@ -136,14 +138,23 @@ bool fdmon_epoll_try_upgrade(AioContext *ctx, unsigned npfd)
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
- if (npfd >= EPOLL_ENABLE_THRESHOLD) {
|
|
||||||
- if (fdmon_epoll_try_enable(ctx)) {
|
|
||||||
- return true;
|
|
||||||
- } else {
|
|
||||||
- fdmon_epoll_disable(ctx);
|
|
||||||
- }
|
|
||||||
+ if (npfd < EPOLL_ENABLE_THRESHOLD) {
|
|
||||||
+ return false;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ /* The list must not change while we add fds to epoll */
|
|
||||||
+ if (!qemu_lockcnt_dec_if_lock(&ctx->list_lock)) {
|
|
||||||
+ return false;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ ok = fdmon_epoll_try_enable(ctx);
|
|
||||||
+
|
|
||||||
+ qemu_lockcnt_inc_and_unlock(&ctx->list_lock);
|
|
||||||
+
|
|
||||||
+ if (!ok) {
|
|
||||||
+ fdmon_epoll_disable(ctx);
|
|
||||||
}
|
|
||||||
- return false;
|
|
||||||
+ return ok;
|
|
||||||
}
|
|
||||||
|
|
||||||
void fdmon_epoll_setup(AioContext *ctx)
|
|
||||||
--
|
|
||||||
2.27.0
|
|
||||||
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user