2015-06-26 17:54:51 +02:00
|
|
|
/*
|
|
|
|
* s390 storage key device
|
|
|
|
*
|
|
|
|
* Copyright 2015 IBM Corp.
|
|
|
|
* Author(s): Jason J. Herne <jjherne@linux.vnet.ibm.com>
|
|
|
|
*
|
|
|
|
* This work is licensed under the terms of the GNU GPL, version 2 or (at
|
|
|
|
* your option) any later version. See the COPYING file in the top-level
|
|
|
|
* directory.
|
|
|
|
*/
|
|
|
|
|
2016-06-29 13:47:03 +02:00
|
|
|
#ifndef S390_STORAGE_KEYS_H
|
|
|
|
#define S390_STORAGE_KEYS_H
|
2015-06-26 17:54:51 +02:00
|
|
|
|
2019-08-12 07:23:51 +02:00
|
|
|
#include "hw/qdev-core.h"
|
2015-06-26 20:07:21 +02:00
|
|
|
#include "monitor/monitor.h"
|
2020-09-03 22:43:22 +02:00
|
|
|
#include "qom/object.h"
|
2015-06-26 17:54:51 +02:00
|
|
|
|
|
|
|
#define TYPE_S390_SKEYS "s390-skeys"
|
2020-09-16 20:25:18 +02:00
|
|
|
OBJECT_DECLARE_TYPE(S390SKeysState, S390SKeysClass, S390_SKEYS)
|
2015-06-26 17:54:51 +02:00
|
|
|
|
2020-09-03 22:43:22 +02:00
|
|
|
struct S390SKeysState {
|
2015-06-26 17:54:51 +02:00
|
|
|
DeviceState parent_obj;
|
2015-07-09 19:56:44 +02:00
|
|
|
bool migration_enabled;
|
2015-06-26 17:54:51 +02:00
|
|
|
|
2020-09-03 22:43:22 +02:00
|
|
|
};
|
2015-06-26 17:54:51 +02:00
|
|
|
|
|
|
|
|
2020-09-03 22:43:22 +02:00
|
|
|
struct S390SKeysClass {
|
2015-06-26 17:54:51 +02:00
|
|
|
DeviceClass parent_class;
|
2021-09-03 17:55:14 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @skeys_are_enabled:
|
|
|
|
*
|
|
|
|
* Check whether storage keys are enabled. If not enabled, they were not
|
|
|
|
* enabled lazily either by the guest via a storage key instruction or
|
|
|
|
* by the host during migration.
|
|
|
|
*
|
|
|
|
* If disabled, everything not explicitly triggered by the guest,
|
|
|
|
* such as outgoing migration or dirty/change tracking, should not touch
|
|
|
|
* storage keys and should not lazily enable it.
|
|
|
|
*
|
|
|
|
* @ks: the #S390SKeysState
|
|
|
|
*
|
|
|
|
* Returns false if not enabled and true if enabled.
|
|
|
|
*/
|
2021-09-03 17:55:13 +02:00
|
|
|
bool (*skeys_are_enabled)(S390SKeysState *ks);
|
2021-09-03 17:55:14 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @enable_skeys:
|
|
|
|
*
|
|
|
|
* Lazily enable storage keys. If this function is not implemented,
|
|
|
|
* setting a storage key will lazily enable storage keys implicitly
|
|
|
|
* instead. TCG guests have to make sure to flush the TLB of all CPUs
|
|
|
|
* if storage keys were not enabled before this call.
|
|
|
|
*
|
|
|
|
* @ks: the #S390SKeysState
|
|
|
|
*
|
|
|
|
* Returns false if not enabled before this call, and true if already
|
|
|
|
* enabled.
|
|
|
|
*/
|
|
|
|
bool (*enable_skeys)(S390SKeysState *ks);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @get_skeys:
|
|
|
|
*
|
|
|
|
* Get storage keys for the given PFN range. This call will fail if
|
|
|
|
* storage keys have not been lazily enabled yet.
|
|
|
|
*
|
|
|
|
* Callers have to validate that a GFN is valid before this call.
|
|
|
|
*
|
|
|
|
* @ks: the #S390SKeysState
|
|
|
|
* @start_gfn: the start GFN to get storage keys for
|
|
|
|
* @count: the number of storage keys to get
|
|
|
|
* @keys: the byte array where storage keys will be stored to
|
|
|
|
*
|
|
|
|
* Returns 0 on success, returns an error if getting a storage key failed.
|
|
|
|
*/
|
2015-06-26 17:54:51 +02:00
|
|
|
int (*get_skeys)(S390SKeysState *ks, uint64_t start_gfn, uint64_t count,
|
|
|
|
uint8_t *keys);
|
2021-09-03 17:55:14 +02:00
|
|
|
/**
|
|
|
|
* @set_skeys:
|
|
|
|
*
|
|
|
|
* Set storage keys for the given PFN range. This call will fail if
|
|
|
|
* storage keys have not been lazily enabled yet and implicit
|
|
|
|
* enablement is not supported.
|
|
|
|
*
|
|
|
|
* Callers have to validate that a GFN is valid before this call.
|
|
|
|
*
|
|
|
|
* @ks: the #S390SKeysState
|
|
|
|
* @start_gfn: the start GFN to set storage keys for
|
|
|
|
* @count: the number of storage keys to set
|
|
|
|
* @keys: the byte array where storage keys will be read from
|
|
|
|
*
|
|
|
|
* Returns 0 on success, returns an error if setting a storage key failed.
|
|
|
|
*/
|
2015-06-26 17:54:51 +02:00
|
|
|
int (*set_skeys)(S390SKeysState *ks, uint64_t start_gfn, uint64_t count,
|
|
|
|
uint8_t *keys);
|
2020-09-03 22:43:22 +02:00
|
|
|
};
|
2015-06-26 17:54:51 +02:00
|
|
|
|
|
|
|
#define TYPE_KVM_S390_SKEYS "s390-skeys-kvm"
|
|
|
|
#define TYPE_QEMU_S390_SKEYS "s390-skeys-qemu"
|
2020-09-03 22:43:22 +02:00
|
|
|
typedef struct QEMUS390SKeysState QEMUS390SKeysState;
|
2020-08-31 23:07:33 +02:00
|
|
|
DECLARE_INSTANCE_CHECKER(QEMUS390SKeysState, QEMU_S390_SKEYS,
|
|
|
|
TYPE_QEMU_S390_SKEYS)
|
2015-06-26 17:54:51 +02:00
|
|
|
|
2020-09-03 22:43:22 +02:00
|
|
|
struct QEMUS390SKeysState {
|
2015-06-26 17:54:51 +02:00
|
|
|
S390SKeysState parent_obj;
|
|
|
|
uint8_t *keydata;
|
|
|
|
uint32_t key_count;
|
2020-09-03 22:43:22 +02:00
|
|
|
};
|
2015-06-26 17:54:51 +02:00
|
|
|
|
|
|
|
void s390_skeys_init(void);
|
|
|
|
|
|
|
|
S390SKeysState *s390_get_skeys_device(void);
|
|
|
|
|
2015-06-26 20:07:21 +02:00
|
|
|
void hmp_dump_skeys(Monitor *mon, const QDict *qdict);
|
2015-06-26 20:10:16 +02:00
|
|
|
void hmp_info_skeys(Monitor *mon, const QDict *qdict);
|
|
|
|
|
2016-06-29 13:47:03 +02:00
|
|
|
#endif /* S390_STORAGE_KEYS_H */
|