|
|
bf143f |
From 8d1a60069cddcc69ef1a6f50f2b55343de348b57 Mon Sep 17 00:00:00 2001
|
|
|
bf143f |
From: Janis Schoetterl-Glausch <scgl@linux.ibm.com>
|
|
|
bf143f |
Date: Fri, 6 May 2022 17:39:56 +0200
|
|
|
bf143f |
Subject: [PATCH 2/3] target/s390x: kvm: Honor storage keys during emulation
|
|
|
bf143f |
MIME-Version: 1.0
|
|
|
bf143f |
Content-Type: text/plain; charset=UTF-8
|
|
|
bf143f |
Content-Transfer-Encoding: 8bit
|
|
|
bf143f |
|
|
|
bf143f |
RH-Author: Cédric Le Goater <None>
|
|
|
bf143f |
RH-MergeRequest: 220: s390x: Fix skey test in kvm_unit_test
|
|
|
bf143f |
RH-Bugzilla: 2124757
|
|
|
bf143f |
RH-Acked-by: Thomas Huth <thuth@redhat.com>
|
|
|
bf143f |
RH-Acked-by: David Hildenbrand <david@redhat.com>
|
|
|
bf143f |
RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
|
|
|
bf143f |
RH-Commit: [2/2] 980dbb4eba8d2f1da7cf4113230d0a6483cffc4f
|
|
|
bf143f |
|
|
|
bf143f |
Storage key controlled protection is currently not honored when
|
|
|
bf143f |
emulating instructions.
|
|
|
bf143f |
If available, enable key protection for the MEM_OP ioctl, thereby
|
|
|
bf143f |
enabling it for the s390_cpu_virt_mem_* functions, when using kvm.
|
|
|
bf143f |
As a result, the emulation of the following instructions honors storage
|
|
|
bf143f |
keys:
|
|
|
bf143f |
|
|
|
bf143f |
* CLP
|
|
|
bf143f |
The Synch I/O CLP command would need special handling in order
|
|
|
bf143f |
to support storage keys, but is currently not supported.
|
|
|
bf143f |
* CHSC
|
|
|
bf143f |
Performing commands asynchronously would require special
|
|
|
bf143f |
handling, but commands are currently always synchronous.
|
|
|
bf143f |
* STSI
|
|
|
bf143f |
* TSCH
|
|
|
bf143f |
Must (and does) not change channel if terminated due to
|
|
|
bf143f |
protection.
|
|
|
bf143f |
* MSCH
|
|
|
bf143f |
Suppressed on protection, works because fetching instruction.
|
|
|
bf143f |
* SSCH
|
|
|
bf143f |
Suppressed on protection, works because fetching instruction.
|
|
|
bf143f |
* STSCH
|
|
|
bf143f |
* STCRW
|
|
|
bf143f |
Suppressed on protection, this works because no partial store is
|
|
|
bf143f |
possible, because the operand cannot span multiple pages.
|
|
|
bf143f |
* PCISTB
|
|
|
bf143f |
* MPCIFC
|
|
|
bf143f |
* STPCIFC
|
|
|
bf143f |
|
|
|
bf143f |
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2124757
|
|
|
bf143f |
|
|
|
bf143f |
Signed-off-by: Janis Schoetterl-Glausch <scgl@linux.ibm.com>
|
|
|
bf143f |
Message-Id: <20220506153956.2217601-3-scgl@linux.ibm.com>
|
|
|
bf143f |
Signed-off-by: Thomas Huth <thuth@redhat.com>
|
|
|
bf143f |
(cherry picked from commit 54354861d21b69ec0781f43e67b8d4f6edad7e3f)
|
|
|
bf143f |
Signed-off-by: Cédric Le Goater <clg@redhat.com>
|
|
|
bf143f |
---
|
|
|
bf143f |
target/s390x/kvm/kvm.c | 9 +++++++++
|
|
|
bf143f |
1 file changed, 9 insertions(+)
|
|
|
bf143f |
|
|
|
bf143f |
diff --git a/target/s390x/kvm/kvm.c b/target/s390x/kvm/kvm.c
|
|
|
bf143f |
index c52434985b..ba04997da1 100644
|
|
|
bf143f |
--- a/target/s390x/kvm/kvm.c
|
|
|
bf143f |
+++ b/target/s390x/kvm/kvm.c
|
|
|
bf143f |
@@ -152,12 +152,15 @@ const KVMCapabilityInfo kvm_arch_required_capabilities[] = {
|
|
|
bf143f |
static int cap_sync_regs;
|
|
|
bf143f |
static int cap_async_pf;
|
|
|
bf143f |
static int cap_mem_op;
|
|
|
bf143f |
+static int cap_mem_op_extension;
|
|
|
bf143f |
static int cap_s390_irq;
|
|
|
bf143f |
static int cap_ri;
|
|
|
bf143f |
static int cap_hpage_1m;
|
|
|
bf143f |
static int cap_vcpu_resets;
|
|
|
bf143f |
static int cap_protected;
|
|
|
bf143f |
|
|
|
bf143f |
+static bool mem_op_storage_key_support;
|
|
|
bf143f |
+
|
|
|
bf143f |
static int active_cmma;
|
|
|
bf143f |
|
|
|
bf143f |
static int kvm_s390_query_mem_limit(uint64_t *memory_limit)
|
|
|
bf143f |
@@ -355,6 +358,8 @@ int kvm_arch_init(MachineState *ms, KVMState *s)
|
|
|
bf143f |
cap_sync_regs = kvm_check_extension(s, KVM_CAP_SYNC_REGS);
|
|
|
bf143f |
cap_async_pf = kvm_check_extension(s, KVM_CAP_ASYNC_PF);
|
|
|
bf143f |
cap_mem_op = kvm_check_extension(s, KVM_CAP_S390_MEM_OP);
|
|
|
bf143f |
+ cap_mem_op_extension = kvm_check_extension(s, KVM_CAP_S390_MEM_OP_EXTENSION);
|
|
|
bf143f |
+ mem_op_storage_key_support = cap_mem_op_extension > 0;
|
|
|
bf143f |
cap_s390_irq = kvm_check_extension(s, KVM_CAP_S390_INJECT_IRQ);
|
|
|
bf143f |
cap_vcpu_resets = kvm_check_extension(s, KVM_CAP_S390_VCPU_RESETS);
|
|
|
bf143f |
cap_protected = kvm_check_extension(s, KVM_CAP_S390_PROTECTED);
|
|
|
bf143f |
@@ -843,6 +848,7 @@ int kvm_s390_mem_op(S390CPU *cpu, vaddr addr, uint8_t ar, void *hostbuf,
|
|
|
bf143f |
: KVM_S390_MEMOP_LOGICAL_READ,
|
|
|
bf143f |
.buf = (uint64_t)hostbuf,
|
|
|
bf143f |
.ar = ar,
|
|
|
bf143f |
+ .key = (cpu->env.psw.mask & PSW_MASK_KEY) >> PSW_SHIFT_KEY,
|
|
|
bf143f |
};
|
|
|
bf143f |
int ret;
|
|
|
bf143f |
|
|
|
bf143f |
@@ -852,6 +858,9 @@ int kvm_s390_mem_op(S390CPU *cpu, vaddr addr, uint8_t ar, void *hostbuf,
|
|
|
bf143f |
if (!hostbuf) {
|
|
|
bf143f |
mem_op.flags |= KVM_S390_MEMOP_F_CHECK_ONLY;
|
|
|
bf143f |
}
|
|
|
bf143f |
+ if (mem_op_storage_key_support) {
|
|
|
bf143f |
+ mem_op.flags |= KVM_S390_MEMOP_F_SKEY_PROTECTION;
|
|
|
bf143f |
+ }
|
|
|
bf143f |
|
|
|
bf143f |
ret = kvm_vcpu_ioctl(CPU(cpu), KVM_S390_MEM_OP, &mem_op);
|
|
|
bf143f |
if (ret < 0) {
|
|
|
bf143f |
--
|
|
|
bf143f |
2.35.3
|
|
|
bf143f |
|