spapr: nested: Introduce H_GUEST_[GET|SET]_STATE hcalls.

Introduce the nested PAPR hcalls:
    - H_GUEST_GET_STATE which is used to get state of a nested guest or
      a guest VCPU. The value field for each element in the request is
      destination to be updated to reflect current state on success.
    - H_GUEST_SET_STATE which is used to modify the state of a guest or
      a guest VCPU. On success, guest (or its VCPU) state shall be
      updated as per the value field for the requested element(s).

Reviewed-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Michael Neuling <mikey@neuling.org>
Signed-off-by: Harsh Prateek Bora <harshpb@linux.ibm.com>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
This commit is contained in:
Harsh Prateek Bora 2024-03-08 16:49:37 +05:30 committed by Nicholas Piggin
parent 4a575f9a05
commit 64c43909b2
3 changed files with 294 additions and 0 deletions

View file

@ -366,6 +366,7 @@ struct SpaprMachineState {
#define H_OVERLAP -68
#define H_STATE -75
#define H_IN_USE -77
#define H_INVALID_ELEMENT_VALUE -81
#define H_UNSUPPORTED_FLAG -256
#define H_MULTI_THREADS_ACTIVE -9005
@ -589,6 +590,8 @@ struct SpaprMachineState {
#define H_GUEST_SET_CAPABILITIES 0x464
#define H_GUEST_CREATE 0x470
#define H_GUEST_CREATE_VCPU 0x474
#define H_GUEST_GET_STATE 0x478
#define H_GUEST_SET_STATE 0x47C
#define H_GUEST_DELETE 0x488
#define MAX_HCALL_OPCODE H_GUEST_DELETE

View file

@ -224,6 +224,10 @@ typedef struct SpaprMachineStateNestedGuest {
#define HVMASK_MSR 0xEBFFFFFFFFBFEFFF
#define HVMASK_HDEXCR 0x00000000FFFFFFFF
#define HVMASK_TB_OFFSET 0x000000FFFFFFFFFF
#define GSB_MAX_BUF_SIZE (1024 * 1024)
#define H_GUEST_GETSET_STATE_FLAG_GUEST_WIDE 0x8000000000000000
#define GUEST_STATE_REQUEST_GUEST_WIDE 0x1
#define GUEST_STATE_REQUEST_SET 0x2
/*
* As per ISA v3.1B, following bits are reserved:
@ -322,6 +326,25 @@ typedef struct SpaprMachineStateNestedGuest {
#define GSE_ENV_DWM(i, f, m) \
GUEST_STATE_ELEMENT_MSK(i, 8, f, copy_state_8to8, m)
struct guest_state_element {
uint16_t id;
uint16_t size;
uint8_t value[];
} QEMU_PACKED;
struct guest_state_buffer {
uint32_t num_elements;
struct guest_state_element elements[];
} QEMU_PACKED;
/* Actual buffer plus some metadata about the request */
struct guest_state_request {
struct guest_state_buffer *gsb;
int64_t buf;
int64_t len;
uint16_t flags;
};
/*
* Register state for entering a nested guest with H_ENTER_NESTED.
* New member must be added at the end.