update code

This commit is contained in:
zhuchunyi 2019-11-06 19:50:55 +08:00
parent 9a683b2a29
commit f0229b47e9
5 changed files with 1137 additions and 12 deletions

1
80-kvm.rules Normal file
View File

@ -0,0 +1 @@
KERNEL=="kvm", GROUP="kvm", MODE="0660"

View File

@ -1,7 +1,7 @@
From 70063948181062161a341a8738a53708d8ed0a0b Mon Sep 17 00:00:00 2001
From: Xu Yandong <xuyandong2@huawei.com>
Date: Wed, 28 Aug 2019 01:36:21 -0400
Subject: [PATCH] cpu: add Kunpeng-T82 cpu support
Subject: [PATCH] cpu: add Kunpeng-920 cpu support
Signed-off-by: Xu Yandong <xuyandong2@huawei.com>
---
@ -17,7 +17,7 @@ index f89757df..11468b72 100644
ARM_CPU_TYPE_NAME("cortex-a53"),
ARM_CPU_TYPE_NAME("cortex-a57"),
ARM_CPU_TYPE_NAME("cortex-a72"),
+ ARM_CPU_TYPE_NAME("Kunpeng-T82"),
+ ARM_CPU_TYPE_NAME("Kunpeng-920"),
ARM_CPU_TYPE_NAME("host"),
ARM_CPU_TYPE_NAME("max"),
};
@ -29,12 +29,12 @@ index 228906f2..5581d5e1 100644
define_arm_cp_regs(cpu, cortex_a72_a57_a53_cp_reginfo);
}
+static void aarch64_kunpeng_t82_initfn(Object *obj)
+static void aarch64_kunpeng_920_initfn(Object *obj)
+{
+ ARMCPU *cpu = ARM_CPU(obj);
+
+ /*
+ * Hisilicon Kunpeng-T82 CPU is based on cortex-a72,
+ * Hisilicon Kunpeng-920 CPU is similar to cortex-a72,
+ * so first initialize cpu data as cortex-a72 CPU,
+ * and then update the special registers.
+ */
@ -56,7 +56,7 @@ index 228906f2..5581d5e1 100644
{ .name = "cortex-a57", .initfn = aarch64_a57_initfn },
{ .name = "cortex-a53", .initfn = aarch64_a53_initfn },
{ .name = "cortex-a72", .initfn = aarch64_a72_initfn },
+ { .name = "Kunpeng-T82", .initfn = aarch64_kunpeng_t82_initfn },
+ { .name = "Kunpeng-920", .initfn = aarch64_kunpeng_920_initfn },
{ .name = "max", .initfn = aarch64_max_initfn },
{ .name = NULL }
};

View File

@ -0,0 +1,99 @@
From 7381599d4222f9b5cff6935a66e8b311af77f620 Mon Sep 17 00:00:00 2001
From: Li Mingwang <limingwang@huawei.com>
Date: Thu, 17 Oct 2019 16:57:52 +0800
Subject: [PATCH] Subject: [PATCH] pcie: disable the PCI_EXP_LINKSTA_DLLA cap
for pcie-root-port by default
If the PCI_EXP_LNKSTA_DLLLA capability is set by default, linux
kernel will send PDC event to detect whether there is a device in
pcie slot. If a device is pluged in the pcie-root-port at the same
time, hot-plug device will send ABP + PDC events to the kernel. The
VM kernel will wrongly unplug the device if two PDC events get too
close. Thus we'd better set the PCI_EXP_LNKSTA_DLLLA capability only
in hotplug scenario
Signed-off-by: Li Mingwang <limingwang@huawei.com>
---
hw/core/machine.c | 1 +
hw/pci-bridge/gen_pcie_root_port.c | 1 +
hw/pci/pcie.c | 18 ++++++++++++++----
include/hw/pci/pcie_port.h | 2 ++
4 files changed, 18 insertions(+), 4 deletions(-)
diff --git a/hw/core/machine.c b/hw/core/machine.c
index 5d046a43..29a708da 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -30,6 +30,7 @@ const size_t hw_compat_4_0_len = G_N_ELEMENTS(hw_compat_4_0);
GlobalProperty hw_compat_3_1[] = {
{ "pcie-root-port", "x-speed", "2_5" },
{ "pcie-root-port", "x-width", "1" },
+ { "pcie-root-port", "fast-plug", "0" },
{ "memory-backend-file", "x-use-canonical-path-for-ramblock-id", "true" },
{ "memory-backend-memfd", "x-use-canonical-path-for-ramblock-id", "true" },
{ "tpm-crb", "ppi", "false" },
diff --git a/hw/pci-bridge/gen_pcie_root_port.c b/hw/pci-bridge/gen_pcie_root_port.c
index 26bda73e..3179c4ea 100644
--- a/hw/pci-bridge/gen_pcie_root_port.c
+++ b/hw/pci-bridge/gen_pcie_root_port.c
@@ -131,6 +131,7 @@ static Property gen_rp_props[] = {
speed, PCIE_LINK_SPEED_16),
DEFINE_PROP_PCIE_LINK_WIDTH("x-width", PCIESlot,
width, PCIE_LINK_WIDTH_32),
+ DEFINE_PROP_UINT8("fast-plug", PCIESlot, disable_lnksta_dllla, 0),
DEFINE_PROP_END_OF_LIST()
};
diff --git a/hw/pci/pcie.c b/hw/pci/pcie.c
index cf1ca30f..c0d6ff13 100644
--- a/hw/pci/pcie.c
+++ b/hw/pci/pcie.c
@@ -50,6 +50,7 @@ pcie_cap_v1_fill(PCIDevice *dev, uint8_t port, uint8_t type, uint8_t version)
{
uint8_t *exp_cap = dev->config + dev->exp.exp_cap;
uint8_t *cmask = dev->cmask + dev->exp.exp_cap;
+ PCIESlot *s = (PCIESlot *)object_dynamic_cast(OBJECT(dev), TYPE_PCIE_SLOT);
/* capability register
interrupt message number defaults to 0 */
@@ -76,11 +77,20 @@ pcie_cap_v1_fill(PCIDevice *dev, uint8_t port, uint8_t type, uint8_t version)
QEMU_PCI_EXP_LNKSTA_NLW(QEMU_PCI_EXP_LNK_X1) |
QEMU_PCI_EXP_LNKSTA_CLS(QEMU_PCI_EXP_LNK_2_5GT));
- if (dev->cap_present & QEMU_PCIE_LNKSTA_DLLLA) {
- pci_word_test_and_set_mask(exp_cap + PCI_EXP_LNKSTA,
- PCI_EXP_LNKSTA_DLLLA);
+ /* If a device is plugged in the pcie-root-port when VM kernel
+ * is just booting, the kernel will wrongly disable the device.
+ * This bug was brought in two patches of the linux kernel, i.e.
+ * https://patchwork.kernel.org/patch/10575355/ and
+ * https://patchwork.kernel.org/patch/10766219/.
+ * To fix this up, let's enable the PCI_EXP_LNKSTA_DLLLA
+ * only if it is a PCIESlot device.
+ */
+ if (s == NULL || s->disable_lnksta_dllla == 0) {
+ if (dev->cap_present & QEMU_PCIE_LNKSTA_DLLLA) {
+ pci_word_test_and_set_mask(exp_cap + PCI_EXP_LNKSTA,
+ PCI_EXP_LNKSTA_DLLLA);
+ }
}
-
/* We changed link status bits over time, and changing them across
* migrations is generally fine as hardware changes them too.
* Let's not bother checking.
diff --git a/include/hw/pci/pcie_port.h b/include/hw/pci/pcie_port.h
index 09586f46..c3969921 100644
--- a/include/hw/pci/pcie_port.h
+++ b/include/hw/pci/pcie_port.h
@@ -50,6 +50,8 @@ struct PCIESlot {
uint8_t chassis;
uint16_t slot;
+ uint8_t disable_lnksta_dllla;
+
PCIExpLinkSpeed speed;
PCIExpLinkWidth width;
--
2.19.1

View File

@ -6,8 +6,9 @@ Summary: QEMU is a generic and open source machine emulator and virtualizer
License: GPLv2 and BSD and MIT and CC-BY
URL: http://www.qemu.org
Source0: https://www.qemu.org/download/%{name}-%{version}%{?rcstr}.tar.xz
Source1: 99-qemu-guest-agent.rules
Source2: bridge.conf
Source1: 80-kvm.rules
Source2: 99-qemu-guest-agent.rules
Source3: bridge.conf
Patch0001: qxl-check-release-info-object.patch
Patch0002: target-i386-define-md-clear-bit.patch
@ -56,9 +57,11 @@ Patch0044: memory-unref-the-memory-region-in-simplify-flatview.patch
Patch0045: scsi-lsi-exit-infinite-loop-while-executing-script-C.patch
Patch0046: util-async-hold-AioContext-ref-to-prevent-use-after-.patch
Patch0047: vhost-user-scsi-prevent-using-uninitialized-vqs.patch
Patch0048: cpu-add-Kunpeng-T82-cpu-support.patch
Patch0048: cpu-add-Kunpeng-920-cpu-support.patch
Patch0049: cpu-parse-feature-to-avoid-failure.patch
Patch0050: cpu-add-Cortex-A72-processor-kvm-target-support.patch
Patch0051: vnc-fix-memory-leak-when-vnc-disconnect.patch
Patch0052: pcie-disable-the-PCI_EXP_LINKSTA_DLLA-cap.patch
BuildRequires: flex
BuildRequires: bison
@ -219,11 +222,14 @@ make %{?_smp_mflags} DESTDIR=%{buildroot} \
%find_lang %{name}
install -m 0755 qemu-kvm %{buildroot}%{_libexecdir}/
rm $RPM_BUILD_ROOT%{_bindir}/qemu-system-*
ln -s %{_libexecdir}/qemu-kvm %{buildroot}/%{_bindir}/qemu-kvm
rm %{buildroot}/%{_bindir}/qemu-system-*
install -D -p -m 0644 contrib/systemd/qemu-pr-helper.service %{buildroot}%{_unitdir}/qemu-pr-helper.service
install -D -p -m 0644 contrib/systemd/qemu-pr-helper.socket %{buildroot}%{_unitdir}/qemu-pr-helper.socket
install -D -p -m 0644 qemu.sasl %{buildroot}%{_sysconfdir}/sasl2/qemu.conf
install -D -m 0644 %{_sourcedir}/bridge.conf %{buildroot}%{_sysconfdir}/qemu/bridge.conf
install -D -m 0644 %{_sourcedir}/80-kvm.rules %{buildroot}/usr/lib/udev/rules.d/80-kvm.rules
# For qemu-guest-agent package
%global _udevdir /lib/udev/rules.d
@ -288,6 +294,7 @@ getent passwd qemu >/dev/null || \
%files -f %{name}.lang
%dir %{_datadir}/%{name}/
%{_libexecdir}/qemu-kvm
%{_bindir}/qemu-kvm
%{_datadir}/%{name}/efi-virtio.rom
%{_datadir}/%{name}/efi-e1000.rom
%{_datadir}/%{name}/efi-e1000e.rom
@ -317,6 +324,10 @@ getent passwd qemu >/dev/null || \
%config(noreplace) %{_sysconfdir}/sasl2/qemu.conf
%dir %{_sysconfdir}/qemu
%config(noreplace) %{_sysconfdir}/qemu/bridge.conf
/usr/lib/udev/rules.d/80-kvm.rules
%doc %{qemudocdir}/COPYING
%doc %{qemudocdir}/COPYING.LIB
%doc %{qemudocdir}/LICENSE
%ifarch x86_64
%{_datadir}/%{name}/bios.bin
%{_datadir}/%{name}/bios-256k.bin
@ -344,9 +355,6 @@ getent passwd qemu >/dev/null || \
%doc %{qemudocdir}/qemu-qmp-ref.txt
%doc %{qemudocdir}/README
%doc %{qemudocdir}/Changelog
%doc %{qemudocdir}/COPYING
%doc %{qemudocdir}/COPYING.LIB
%doc %{qemudocdir}/LICENSE
%{_mandir}/man1/qemu.1*
%{_mandir}/man1/virtfs-proxy-helper.1*
%{_mandir}/man7/qemu-block-drivers.7*
@ -371,6 +379,9 @@ getent passwd qemu >/dev/null || \
%changelog
* Thu Oct 17 2019 backport from qemu upstream
- vnc-fix-memory-leak-when-vnc-disconnect.patch
* Mon Sep 9 2019 backport from qemu upstream
- ehci-fix-queue-dev-null-ptr-dereference.patch
- memory-unref-the-memory-region-in-simplify-flatview.patch

File diff suppressed because it is too large Load Diff