af68a7132d
- Updating to Sphinx v3.1.2 in Factory is exposing an issue in qemu doc sources. Fix it docs-fix-trace-docs-build-with-sphinx-3..patch - Fix DoS possibility in ati-vga emulation (CVE-2020-13800 bsc#1172495) ati-vga-check-mm_index-before-recursive-.patch - Fix DoS possibility in Network Block Device (nbd) support infrastructure (CVE-2020-10761 bsc#1172710) nbd-server-Avoid-long-error-message-asse.patch - Fix null pointer dereference possibility (DoS) in MegaRAID SAS 8708EM2 emulation (CVE-2020-13659 bsc#1172386) exec-set-map-length-to-zero-when-returni.patch - Fix OOB access possibility in MegaRAID SAS 8708EM2 emulation (CVE-2020-13362 bsc#1172383) megasas-use-unsigned-type-for-reply_queu.patch - Fix legacy IGD passthrough hw-vfio-pci-quirks-Fix-broken-legacy-IGD.patch - The latest gcc10 available in Factory has the fix for the issue this patch was created to avoid, so drop it build-Work-around-gcc10-bug-by-not-using.patch - Switch to upstream versions of some patches we carry add-enum-cast-to-avoid-gcc10-warning.patch -> golan-Add-explicit-type-casts-for-nodnic.patch Be-explicit-about-fcommon-compiler-direc.patch -> build-Be-explicit-about-fcommon-compiler.patch Do-not-apply-WORKAROUND_CFLAGS-for-host-.patch -> build-Do-not-apply-WORKAROUND_CFLAGS-for.patch Fix-s-directive-argument-is-null-error.patch -> build-Fix-s-directive-argument-is-null-e.patch Workaround-compilation-error-with-gcc-9..patch -> build-Workaround-compilation-error-with-.patch work-around-gcc10-problem-with-zero-leng.patch -> intel-Avoid-spurious-compiler-warning-on.patch - Fix vgabios issue for cirrus graphics emulation, which effectively downgraded it to standard VGA behavior vga-fix-cirrus-bios.patch - Fix OOB access possibility in ES1370 audio device emulation (CVE-2020-13361 bsc#1172384) es1370-check-total-frame-count-against-c.patch OBS-URL: https://build.opensuse.org/request/show/822154 OBS-URL: https://build.opensuse.org/package/show/Virtualization/qemu?expand=0&rev=553
136 lines
5.0 KiB
Diff
136 lines
5.0 KiB
Diff
From: Janosch Frank <frankja@linux.ibm.com>
|
|
Date: Wed, 5 Feb 2020 06:57:35 -0500
|
|
Subject: s390x: Add SIDA memory ops
|
|
|
|
Git-commit a9f21cec3bc9c86062c7c24bb2143d22cb3c2950
|
|
References: bsc#1167075
|
|
|
|
Protected guests save the instruction control blocks in the SIDA
|
|
instead of QEMU/KVM directly accessing the guest's memory.
|
|
|
|
Let's introduce new functions to access the SIDA.
|
|
|
|
The memops for doing so are available with KVM_CAP_S390_PROTECTED, so
|
|
let's check for that.
|
|
|
|
Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
|
|
Reviewed-by: David Hildenbrand <david@redhat.com>
|
|
Reviewed-by: Christian Borntraeger <borntraeger@de.ibm.com>
|
|
Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
|
|
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
|
|
Signed-off-by: Bruce Rogers <brogers@suse.com>
|
|
---
|
|
target/s390x/cpu.h | 7 ++++++-
|
|
target/s390x/kvm.c | 26 ++++++++++++++++++++++++++
|
|
target/s390x/kvm_s390x.h | 2 ++
|
|
target/s390x/mmu_helper.c | 14 ++++++++++++++
|
|
4 files changed, 48 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/target/s390x/cpu.h b/target/s390x/cpu.h
|
|
index 1d17709d6e10b5e0668bc09e21c7..035427521cec252877c70288d597 100644
|
|
--- a/target/s390x/cpu.h
|
|
+++ b/target/s390x/cpu.h
|
|
@@ -823,7 +823,12 @@ int s390_cpu_virt_mem_rw(S390CPU *cpu, vaddr laddr, uint8_t ar, void *hostbuf,
|
|
#define s390_cpu_virt_mem_check_write(cpu, laddr, ar, len) \
|
|
s390_cpu_virt_mem_rw(cpu, laddr, ar, NULL, len, true)
|
|
void s390_cpu_virt_mem_handle_exc(S390CPU *cpu, uintptr_t ra);
|
|
-
|
|
+int s390_cpu_pv_mem_rw(S390CPU *cpu, unsigned int offset, void *hostbuf,
|
|
+ int len, bool is_write);
|
|
+#define s390_cpu_pv_mem_read(cpu, offset, dest, len) \
|
|
+ s390_cpu_pv_mem_rw(cpu, offset, dest, len, false)
|
|
+#define s390_cpu_pv_mem_write(cpu, offset, dest, len) \
|
|
+ s390_cpu_pv_mem_rw(cpu, offset, dest, len, true)
|
|
|
|
/* sigp.c */
|
|
int s390_cpu_restart(S390CPU *cpu);
|
|
diff --git a/target/s390x/kvm.c b/target/s390x/kvm.c
|
|
index 1988809ec2e7b1b6db33ba85eaef..0e93778ed15d0e04e83eff1baccf 100644
|
|
--- a/target/s390x/kvm.c
|
|
+++ b/target/s390x/kvm.c
|
|
@@ -154,6 +154,7 @@ static int cap_ri;
|
|
static int cap_gs;
|
|
static int cap_hpage_1m;
|
|
static int cap_vcpu_resets;
|
|
+static int cap_protected;
|
|
|
|
static int active_cmma;
|
|
|
|
@@ -351,6 +352,7 @@ int kvm_arch_init(MachineState *ms, KVMState *s)
|
|
cap_mem_op = kvm_check_extension(s, KVM_CAP_S390_MEM_OP);
|
|
cap_s390_irq = kvm_check_extension(s, KVM_CAP_S390_INJECT_IRQ);
|
|
cap_vcpu_resets = kvm_check_extension(s, KVM_CAP_S390_VCPU_RESETS);
|
|
+ cap_protected = kvm_check_extension(s, KVM_CAP_S390_PROTECTED);
|
|
|
|
if (!kvm_check_extension(s, KVM_CAP_S390_GMAP)
|
|
|| !kvm_check_extension(s, KVM_CAP_S390_COW)) {
|
|
@@ -851,6 +853,30 @@ int kvm_s390_mem_op(S390CPU *cpu, vaddr addr, uint8_t ar, void *hostbuf,
|
|
return ret;
|
|
}
|
|
|
|
+int kvm_s390_mem_op_pv(S390CPU *cpu, uint64_t offset, void *hostbuf,
|
|
+ int len, bool is_write)
|
|
+{
|
|
+ struct kvm_s390_mem_op mem_op = {
|
|
+ .sida_offset = offset,
|
|
+ .size = len,
|
|
+ .op = is_write ? KVM_S390_MEMOP_SIDA_WRITE
|
|
+ : KVM_S390_MEMOP_SIDA_READ,
|
|
+ .buf = (uint64_t)hostbuf,
|
|
+ };
|
|
+ int ret;
|
|
+
|
|
+ if (!cap_mem_op || !cap_protected) {
|
|
+ return -ENOSYS;
|
|
+ }
|
|
+
|
|
+ ret = kvm_vcpu_ioctl(CPU(cpu), KVM_S390_MEM_OP, &mem_op);
|
|
+ if (ret < 0) {
|
|
+ error_report("KVM_S390_MEM_OP failed: %s", strerror(-ret));
|
|
+ abort();
|
|
+ }
|
|
+ return ret;
|
|
+}
|
|
+
|
|
/*
|
|
* Legacy layout for s390:
|
|
* Older S390 KVM requires the topmost vma of the RAM to be
|
|
diff --git a/target/s390x/kvm_s390x.h b/target/s390x/kvm_s390x.h
|
|
index dea813f450153c34e1269424772d..6ab17c81b73a0011e32213552698 100644
|
|
--- a/target/s390x/kvm_s390x.h
|
|
+++ b/target/s390x/kvm_s390x.h
|
|
@@ -19,6 +19,8 @@ void kvm_s390_vcpu_interrupt(S390CPU *cpu, struct kvm_s390_irq *irq);
|
|
void kvm_s390_access_exception(S390CPU *cpu, uint16_t code, uint64_t te_code);
|
|
int kvm_s390_mem_op(S390CPU *cpu, vaddr addr, uint8_t ar, void *hostbuf,
|
|
int len, bool is_write);
|
|
+int kvm_s390_mem_op_pv(S390CPU *cpu, vaddr addr, void *hostbuf, int len,
|
|
+ bool is_write);
|
|
void kvm_s390_program_interrupt(S390CPU *cpu, uint16_t code);
|
|
int kvm_s390_set_cpu_state(S390CPU *cpu, uint8_t cpu_state);
|
|
void kvm_s390_vcpu_interrupt_pre_save(S390CPU *cpu);
|
|
diff --git a/target/s390x/mmu_helper.c b/target/s390x/mmu_helper.c
|
|
index 0be2f300bbe4ac8b68619b8c2285..7d9f3059cd502c49108b459c8d23 100644
|
|
--- a/target/s390x/mmu_helper.c
|
|
+++ b/target/s390x/mmu_helper.c
|
|
@@ -474,6 +474,20 @@ static int translate_pages(S390CPU *cpu, vaddr addr, int nr_pages,
|
|
return 0;
|
|
}
|
|
|
|
+int s390_cpu_pv_mem_rw(S390CPU *cpu, unsigned int offset, void *hostbuf,
|
|
+ int len, bool is_write)
|
|
+{
|
|
+ int ret;
|
|
+
|
|
+ if (kvm_enabled()) {
|
|
+ ret = kvm_s390_mem_op_pv(cpu, offset, hostbuf, len, is_write);
|
|
+ } else {
|
|
+ /* Protected Virtualization is a KVM/Hardware only feature */
|
|
+ g_assert_not_reached();
|
|
+ }
|
|
+ return ret;
|
|
+}
|
|
+
|
|
/**
|
|
* s390_cpu_virt_mem_rw:
|
|
* @laddr: the logical start address
|