[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 16/20] hw/s390x/s390-skeys: check if an address is valid before du
From: |
Thomas Huth |
Subject: |
[PULL 16/20] hw/s390x/s390-skeys: check if an address is valid before dumping the key |
Date: |
Tue, 7 Sep 2021 15:14:45 +0200 |
From: David Hildenbrand <david@redhat.com>
Let's validate the given address and report a proper error in case it's
not. All call paths now properly check the validity of the given GFN.
Remove the TODO.
The errors inside the getter and setter should only trigger if something
really goes wrong now, for example, with a broken migration stream. Or
when we forget to update the storage key allocation with memory hotplug.
Signed-off-by: David Hildenbrand <david@redhat.com>
Acked-by: Thomas Huth <thuth@redhat.com>
Message-Id: <20210903155514.44772-12-david@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
hw/s390x/s390-skeys.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/hw/s390x/s390-skeys.c b/hw/s390x/s390-skeys.c
index 56a47fe180..db73e9091d 100644
--- a/hw/s390x/s390-skeys.c
+++ b/hw/s390x/s390-skeys.c
@@ -18,6 +18,7 @@
#include "qapi/qmp/qdict.h"
#include "qemu/error-report.h"
#include "sysemu/memory_mapping.h"
+#include "exec/address-spaces.h"
#include "sysemu/kvm.h"
#include "migration/qemu-file-types.h"
#include "migration/register.h"
@@ -86,6 +87,13 @@ void hmp_info_skeys(Monitor *mon, const QDict *qdict)
return;
}
+ if (!address_space_access_valid(&address_space_memory,
+ addr & TARGET_PAGE_MASK, TARGET_PAGE_SIZE,
+ false, MEMTXATTRS_UNSPECIFIED)) {
+ monitor_printf(mon, "Error: The given address is not valid\n");
+ return;
+ }
+
r = skeyclass->get_skeys(ss, addr / TARGET_PAGE_SIZE, 1, &key);
if (r < 0) {
monitor_printf(mon, "Error: %s\n", strerror(-r));
@@ -197,11 +205,6 @@ static int qemu_s390_skeys_enabled(S390SKeysState *ss)
return 1;
}
-/*
- * TODO: for memory hotplug support qemu_s390_skeys_set and qemu_s390_skeys_get
- * will have to make sure that the given gfn belongs to a memory region and not
- * a memory hole.
- */
static int qemu_s390_skeys_set(S390SKeysState *ss, uint64_t start_gfn,
uint64_t count, uint8_t *keys)
{
--
2.27.0
- [PULL 05/20] s390x/ioinst: Fix wrong MSCH alignment check on little endian, (continued)
- [PULL 05/20] s390x/ioinst: Fix wrong MSCH alignment check on little endian, Thomas Huth, 2021/09/07
- [PULL 08/20] s390x/tcg: convert real to absolute address for RRBE, SSKE and ISKE, Thomas Huth, 2021/09/07
- [PULL 06/20] s390x/tcg: wrap address for RRBE, Thomas Huth, 2021/09/07
- [PULL 11/20] s390x/mmu_helper: fixup mmu_translate() documentation, Thomas Huth, 2021/09/07
- [PULL 12/20] s390x/mmu_helper: move address validation into mmu_translate*(), Thomas Huth, 2021/09/07
- [PULL 14/20] hw/s390x/s390-skeys: use memory mapping to detect which storage keys to migrate, Thomas Huth, 2021/09/07
- [PULL 04/20] s390x/tcg: fix and optimize SPX (SET PREFIX), Thomas Huth, 2021/09/07
- [PULL 10/20] s390x/mmu_helper: no need to pass access type to mmu_translate_asce(), Thomas Huth, 2021/09/07
- [PULL 13/20] s390x/mmu_helper: avoid setting the storage key if nothing changed, Thomas Huth, 2021/09/07
- [PULL 17/20] hw/s390x/s390-skeys: rename skeys_enabled to skeys_are_enabled, Thomas Huth, 2021/09/07
- [PULL 16/20] hw/s390x/s390-skeys: check if an address is valid before dumping the key,
Thomas Huth <=
- [PULL 15/20] hw/s390x/s390-skeys: use memory mapping to detect which storage keys to dump, Thomas Huth, 2021/09/07
- [PULL 18/20] hw/s390x/s390-skeys: lazy storage key enablement under TCG, Thomas Huth, 2021/09/07
- [PULL 19/20] s390x: Replace PAGE_SIZE, PAGE_SHIFT and PAGE_MASK, Thomas Huth, 2021/09/07
- [PULL 20/20] s390x/cpumodel: Add more feature to gen16 default model, Thomas Huth, 2021/09/07
- Re: [PULL 00/20] s390x patches, Peter Maydell, 2021/09/07