From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: qemu-devel@nongnu.org
Cc: "Eric Farman" <farman@linux.ibm.com>,
"Peter Maydell" <peter.maydell@linaro.org>,
"Halil Pasic" <pasic@linux.ibm.com>,
"Richard Henderson" <richard.henderson@linaro.org>,
"David Hildenbrand" <david@redhat.com>,
qemu-s390x@nongnu.org, "Ilya Leoshkevich" <iii@linux.ibm.com>,
"Christian Borntraeger" <borntraeger@linux.ibm.com>,
"Mark Cave-Ayland" <mark.cave-ayland@ilande.co.uk>,
"Thomas Huth" <thuth@redhat.com>,
"Stefan Hajnoczi" <stefanha@redhat.com>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>
Subject: [PATCH v2 1/2] hw/s390x: Introduce s390_skeys_get|set() helpers
Date: Thu, 13 Jun 2024 12:44:14 +0200 [thread overview]
Message-ID: <20240613104415.9643-2-philmd@linaro.org> (raw)
In-Reply-To: <20240613104415.9643-1-philmd@linaro.org>
s390_skeys_set() dispatch to S390SKeysClass::set_skeys(),
and s390_skeys_get() to S390SKeysClass::get_skeys().
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
include/hw/s390x/storage-keys.h | 10 ++++++++++
hw/s390x/s390-skeys.c | 27 +++++++++++++++++++++++++++
hw/s390x/trace-events | 4 ++++
3 files changed, 41 insertions(+)
diff --git a/include/hw/s390x/storage-keys.h b/include/hw/s390x/storage-keys.h
index aa2ec2aae5..976ffb2039 100644
--- a/include/hw/s390x/storage-keys.h
+++ b/include/hw/s390x/storage-keys.h
@@ -111,6 +111,16 @@ struct QEMUS390SKeysState {
};
void s390_skeys_init(void);
+/**
+ * @s390_skeys_get: See S390SKeysClass::get_skeys()
+ */
+int s390_skeys_get(S390SKeysState *ks, uint64_t start_gfn,
+ uint64_t count, uint8_t *keys);
+/**
+ * @s390_skeys_set: See S390SKeysClass::set_skeys()
+ */
+int s390_skeys_set(S390SKeysState *ks, uint64_t start_gfn,
+ uint64_t count, uint8_t *keys);
S390SKeysState *s390_get_skeys_device(void);
diff --git a/hw/s390x/s390-skeys.c b/hw/s390x/s390-skeys.c
index 5c535d483e..bf22d6863e 100644
--- a/hw/s390x/s390-skeys.c
+++ b/hw/s390x/s390-skeys.c
@@ -23,6 +23,7 @@
#include "sysemu/kvm.h"
#include "migration/qemu-file-types.h"
#include "migration/register.h"
+#include "trace.h"
#define S390_SKEYS_BUFFER_SIZE (128 * KiB) /* Room for 128k storage keys */
#define S390_SKEYS_SAVE_FLAG_EOS 0x01
@@ -54,6 +55,32 @@ void s390_skeys_init(void)
qdev_realize(DEVICE(obj), NULL, &error_fatal);
}
+int s390_skeys_get(S390SKeysState *ks, uint64_t start_gfn,
+ uint64_t count, uint8_t *keys)
+{
+ S390SKeysClass *kc = S390_SKEYS_GET_CLASS(ks);
+ int rc;
+
+ rc = kc->get_skeys(ks, start_gfn, count, keys);
+ if (rc) {
+ trace_s390_skeys_get_nonzero(rc);
+ }
+ return rc;
+}
+
+int s390_skeys_set(S390SKeysState *ks, uint64_t start_gfn,
+ uint64_t count, uint8_t *keys)
+{
+ S390SKeysClass *kc = S390_SKEYS_GET_CLASS(ks);
+ int rc;
+
+ rc = kc->set_skeys(ks, start_gfn, count, keys);
+ if (rc) {
+ trace_s390_skeys_set_nonzero(rc);
+ }
+ return rc;
+}
+
static void write_keys(FILE *f, uint8_t *keys, uint64_t startgfn,
uint64_t count, Error **errp)
{
diff --git a/hw/s390x/trace-events b/hw/s390x/trace-events
index 34da5ea323..4e74bf4484 100644
--- a/hw/s390x/trace-events
+++ b/hw/s390x/trace-events
@@ -36,3 +36,7 @@ s390_pci_unknown(const char *msg, uint32_t cmd) "%s unknown command 0x%x"
s390_pci_bar(uint32_t bar, uint32_t addr, uint64_t size, uint32_t barsize) "bar %d addr 0x%x size 0x%" PRIx64 "barsize 0x%x"
s390_pci_nodev(const char *cmd, uint32_t fh) "%s no pci dev fh 0x%x"
s390_pci_invalid(const char *cmd, uint32_t fh) "%s invalid space fh 0x%x"
+
+# s390-skeys.c
+s390_skeys_get_nonzero(int rc) "SKEY: Call to get_skeys unexpectedly returned %d"
+s390_skeys_set_nonzero(int rc) "SKEY: Call to set_skeys unexpectedly returned %d"
--
2.41.0
next prev parent reply other threads:[~2024-06-13 10:44 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-13 10:44 [PATCH v2 0/2] target/s390x: Fix tracing header path in TCG mem_helper.c Philippe Mathieu-Daudé
2024-06-13 10:44 ` Philippe Mathieu-Daudé [this message]
2024-06-13 10:44 ` [PATCH v2 2/2] target/s390x: Use s390_skeys_get|set() helper Philippe Mathieu-Daudé
2024-06-18 10:39 ` [PATCH v2 0/2] target/s390x: Fix tracing header path in TCG mem_helper.c Philippe Mathieu-Daudé
2024-06-18 13:04 ` Thomas Huth
2024-06-18 15:11 ` Paolo Bonzini
2024-06-18 15:58 ` Philippe Mathieu-Daudé
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240613104415.9643-2-philmd@linaro.org \
--to=philmd@linaro.org \
--cc=borntraeger@linux.ibm.com \
--cc=david@redhat.com \
--cc=farman@linux.ibm.com \
--cc=iii@linux.ibm.com \
--cc=mark.cave-ayland@ilande.co.uk \
--cc=pasic@linux.ibm.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-s390x@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=stefanha@redhat.com \
--cc=thuth@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).