1 | Changelog: | ||
---|---|---|---|
2 | |||
3 | v3: | ||
4 | - changes that were made to patch 3/5 should have been made in | ||
5 | patch 2/5 | ||
6 | |||
7 | v2: | ||
8 | - removed warnings that weren't needed | ||
9 | - added unregister function | ||
10 | - removed whitelines | ||
11 | - changed variable names for consistency | ||
12 | - removed rc variable and returning 1 or 0 outright | ||
13 | - reversed logics for if statements | ||
14 | - using g_free() instead of free() | ||
15 | - replaced hardcoded numeric values by defining them with #define | ||
16 | in the header | ||
17 | |||
18 | -------------------------------------------------------------------------- | ||
1 | This patch series creates and registers a handler that is called when | 19 | This patch series creates and registers a handler that is called when |
2 | userspace is notified by the kernel that a guest's AP configuration has | 20 | userspace is notified by the kernel that a guest's AP configuration has |
3 | changed. The handler in turn notifies the guest that its AP configuration | 21 | changed. The handler in turn notifies the guest that its AP configuration |
4 | has changed. This allows the guest to immediately respond to AP | 22 | has changed. This allows the guest to immediately respond to AP |
5 | configuration changes rather than relying on polling or some other | 23 | configuration changes rather than relying on polling or some other |
... | ... | ||
12 | hw/vfio/ap: store object indicating AP config changed in a queue | 30 | hw/vfio/ap: store object indicating AP config changed in a queue |
13 | hw/vfio/ap: Storing event information for an AP configuration change | 31 | hw/vfio/ap: Storing event information for an AP configuration change |
14 | event | 32 | event |
15 | s390: implementing CHSC SEI for AP config change | 33 | s390: implementing CHSC SEI for AP config change |
16 | 34 | ||
17 | hw/vfio/ap.c | 74 ++++++++++++++++++++++++++++++++++++ | 35 | hw/vfio/ap.c | 79 ++++++++++++++++++++++++++++++++++++ |
18 | include/hw/s390x/ap-bridge.h | 17 +++++++++ | 36 | include/hw/s390x/ap-bridge.h | 22 ++++++++++ |
19 | linux-headers/linux/vfio.h | 1 + | 37 | linux-headers/linux/vfio.h | 1 + |
20 | target/s390x/ioinst.c | 11 +++++- | 38 | target/s390x/ioinst.c | 11 ++++- |
21 | 4 files changed, 101 insertions(+), 2 deletions(-) | 39 | 4 files changed, 111 insertions(+), 2 deletions(-) |
22 | 40 | ||
23 | -- | 41 | -- |
24 | 2.39.5 (Apple Git-154) | 42 | 2.48.1 | diff view generated by jsdifflib |
... | ... | ||
---|---|---|---|
21 | + VFIO_AP_CFG_CHG_IRQ_INDEX, | 21 | + VFIO_AP_CFG_CHG_IRQ_INDEX, |
22 | VFIO_AP_NUM_IRQS | 22 | VFIO_AP_NUM_IRQS |
23 | }; | 23 | }; |
24 | 24 | ||
25 | -- | 25 | -- |
26 | 2.39.5 (Apple Git-154) | 26 | 2.48.1 | diff view generated by jsdifflib |
1 | Register an event notifier handler to process AP configuration | 1 | Register an event notifier handler to process AP configuration |
---|---|---|---|
2 | change events by queuing the event and generating a CRW to let | 2 | change events by queuing the event and generating a CRW to let |
3 | the guest know its AP configuration has changed | 3 | the guest know its AP configuration has changed |
4 | 4 | ||
5 | Signed-off-by: Rorie Reyes <rreyes@linux.ibm.com> | 5 | Signed-off-by: Rorie Reyes <rreyes@linux.ibm.com> |
6 | Reviewed-by: Anthony Krowiak <akrowiak@linux.ibm.com> | ||
7 | Tested-by: Anthony Krowiak <akrowiak@linux.ibm.com> | ||
8 | --- | 6 | --- |
9 | hw/vfio/ap.c | 27 +++++++++++++++++++++++++++ | 7 | hw/vfio/ap.c | 31 +++++++++++++++++++++++++++++++ |
10 | 1 file changed, 27 insertions(+) | 8 | 1 file changed, 31 insertions(+) |
11 | 9 | ||
12 | diff --git a/hw/vfio/ap.c b/hw/vfio/ap.c | 10 | diff --git a/hw/vfio/ap.c b/hw/vfio/ap.c |
13 | index XXXXXXX..XXXXXXX 100644 | 11 | index XXXXXXX..XXXXXXX 100644 |
14 | --- a/hw/vfio/ap.c | 12 | --- a/hw/vfio/ap.c |
15 | +++ b/hw/vfio/ap.c | 13 | +++ b/hw/vfio/ap.c |
... | ... | ||
36 | +static void vfio_ap_cfg_chg_notifier_handler(void *opaque) | 34 | +static void vfio_ap_cfg_chg_notifier_handler(void *opaque) |
37 | +{ | 35 | +{ |
38 | + VFIOAPDevice *vapdev = opaque; | 36 | + VFIOAPDevice *vapdev = opaque; |
39 | + | 37 | + |
40 | + if (!event_notifier_test_and_clear(&vapdev->cfg_notifier)) { | 38 | + if (!event_notifier_test_and_clear(&vapdev->cfg_notifier)) { |
41 | + warn_report("Event notifier not initialized"); | ||
42 | + return; | 39 | + return; |
43 | + } | 40 | + } |
44 | + | 41 | + |
45 | + css_generate_css_crws(0); | 42 | + css_generate_css_crws(0); |
43 | + | ||
46 | +} | 44 | +} |
47 | + | 45 | + |
48 | static bool vfio_ap_register_irq_notifier(VFIOAPDevice *vapdev, | 46 | static bool vfio_ap_register_irq_notifier(VFIOAPDevice *vapdev, |
49 | unsigned int irq, Error **errp) | 47 | unsigned int irq, Error **errp) |
50 | { | 48 | { |
... | ... | ||
57 | + fd_read = vfio_ap_cfg_chg_notifier_handler; | 55 | + fd_read = vfio_ap_cfg_chg_notifier_handler; |
58 | + break; | 56 | + break; |
59 | default: | 57 | default: |
60 | error_setg(errp, "vfio: Unsupported device irq(%d)", irq); | 58 | error_setg(errp, "vfio: Unsupported device irq(%d)", irq); |
61 | return false; | 59 | return false; |
60 | @@ -XXX,XX +XXX,XX @@ static void vfio_ap_unregister_irq_notifier(VFIOAPDevice *vapdev, | ||
61 | case VFIO_AP_REQ_IRQ_INDEX: | ||
62 | notifier = &vapdev->req_notifier; | ||
63 | break; | ||
64 | + case VFIO_AP_CFG_CHG_IRQ_INDEX: | ||
65 | + notifier = &vapdev->cfg_notifier; | ||
66 | + break; | ||
67 | default: | ||
68 | error_report("vfio: Unsupported device irq(%d)", irq); | ||
69 | return; | ||
62 | @@ -XXX,XX +XXX,XX @@ static void vfio_ap_realize(DeviceState *dev, Error **errp) | 70 | @@ -XXX,XX +XXX,XX @@ static void vfio_ap_realize(DeviceState *dev, Error **errp) |
63 | warn_report_err(err); | 71 | warn_report_err(err); |
64 | } | 72 | } |
65 | 73 | ||
66 | + if (!vfio_ap_register_irq_notifier(vapdev, VFIO_AP_CFG_CHG_IRQ_INDEX, &err)) | 74 | + if (!vfio_ap_register_irq_notifier(vapdev, VFIO_AP_CFG_CHG_IRQ_INDEX, &err)) |
... | ... | ||
73 | + } | 81 | + } |
74 | + | 82 | + |
75 | return; | 83 | return; |
76 | 84 | ||
77 | error: | 85 | error: |
86 | @@ -XXX,XX +XXX,XX @@ static void vfio_ap_unrealize(DeviceState *dev) | ||
87 | VFIOAPDevice *vapdev = VFIO_AP_DEVICE(dev); | ||
88 | |||
89 | vfio_ap_unregister_irq_notifier(vapdev, VFIO_AP_REQ_IRQ_INDEX); | ||
90 | + vfio_ap_unregister_irq_notifier(vapdev, VFIO_AP_CFG_CHG_IRQ_INDEX); | ||
91 | vfio_detach_device(&vapdev->vdev); | ||
92 | g_free(vapdev->vdev.name); | ||
93 | } | ||
78 | -- | 94 | -- |
79 | 2.39.5 (Apple Git-154) | 95 | 2.48.1 | diff view generated by jsdifflib |
1 | Creates an object indicating that an AP configuration change event | 1 | Creates an object indicating that an AP configuration change event |
---|---|---|---|
2 | has been received and stores it in a queue. These objects will later | 2 | has been received and stores it in a queue. These objects will later |
3 | be used to store event information for an AP configuration change | 3 | be used to store event information for an AP configuration change |
4 | when the CHSC instruction is intercepted. | 4 | when the CHSC instruction is intercepted. |
5 | 5 | ||
6 | Signed-off-by: Rorie Reyes <rreyes@linux.ibm.com> | 6 | Signed-off-by: Rorie Reyes <rreyes@linux.ibm.com> |
7 | Reviewed-by: Anthony Krowiak <akrowiak@linux.ibm.com> | ||
8 | Tested-by: Anthony Krowiak <akrowiak@linux.ibm.com> | ||
9 | --- | 7 | --- |
10 | hw/vfio/ap.c | 10 ++++++++++ | 8 | hw/vfio/ap.c | 10 ++++++++++ |
11 | 1 file changed, 10 insertions(+) | 9 | 1 file changed, 10 insertions(+) |
12 | 10 | ||
13 | diff --git a/hw/vfio/ap.c b/hw/vfio/ap.c | 11 | diff --git a/hw/vfio/ap.c b/hw/vfio/ap.c |
... | ... | ||
26 | + QTAILQ_HEAD_INITIALIZER(cfg_chg_events); | 24 | + QTAILQ_HEAD_INITIALIZER(cfg_chg_events); |
27 | + | 25 | + |
28 | OBJECT_DECLARE_SIMPLE_TYPE(VFIOAPDevice, VFIO_AP_DEVICE) | 26 | OBJECT_DECLARE_SIMPLE_TYPE(VFIOAPDevice, VFIO_AP_DEVICE) |
29 | 27 | ||
30 | static void vfio_ap_compute_needs_reset(VFIODevice *vdev) | 28 | static void vfio_ap_compute_needs_reset(VFIODevice *vdev) |
31 | @@ -XXX,XX +XXX,XX @@ static void vfio_ap_cfg_chg_notifier_handler(void *opaque) | 29 | @@ -XXX,XX +XXX,XX @@ static void vfio_ap_req_notifier_handler(void *opaque) |
30 | static void vfio_ap_cfg_chg_notifier_handler(void *opaque) | ||
32 | { | 31 | { |
33 | VFIOAPDevice *vapdev = opaque; | 32 | VFIOAPDevice *vapdev = opaque; |
34 | 33 | + APConfigChgEvent *cfg_chg_event = g_new0(APConfigChgEvent, 1); | |
35 | + APConfigChgEvent *new_event = g_new0(APConfigChgEvent, 1); | 34 | |
35 | if (!event_notifier_test_and_clear(&vapdev->cfg_notifier)) { | ||
36 | return; | ||
37 | } | ||
38 | |||
39 | + QTAILQ_INSERT_TAIL(&cfg_chg_events, cfg_chg_event, next); | ||
36 | + | 40 | + |
37 | + QTAILQ_INSERT_TAIL(&cfg_chg_events, new_event, next); | 41 | css_generate_css_crws(0); |
38 | if (!event_notifier_test_and_clear(&vapdev->cfg_notifier)) { | 42 | |
39 | warn_report("Event notifier not initialized"); | 43 | } |
40 | return; | ||
41 | -- | 44 | -- |
42 | 2.39.5 (Apple Git-154) | 45 | 2.48.1 | diff view generated by jsdifflib |
1 | These functions can be invoked by the function that handles interception | 1 | These functions can be invoked by the function that handles interception |
---|---|---|---|
2 | of the CHSC SEI instruction for requests indicating the accessibility of | 2 | of the CHSC SEI instruction for requests indicating the accessibility of |
3 | one or more adjunct processors has changed. | 3 | one or more adjunct processors has changed. |
4 | 4 | ||
5 | Signed-off-by: Rorie Reyes <rreyes@linux.ibm.com> | 5 | Signed-off-by: Rorie Reyes <rreyes@linux.ibm.com> |
6 | --- | 6 | --- |
7 | hw/vfio/ap.c | 37 ++++++++++++++++++++++++++++++++++++ | 7 | hw/vfio/ap.c | 38 ++++++++++++++++++++++++++++++++++++ |
8 | include/hw/s390x/ap-bridge.h | 17 +++++++++++++++++ | 8 | include/hw/s390x/ap-bridge.h | 22 +++++++++++++++++++++ |
9 | 2 files changed, 54 insertions(+) | 9 | 2 files changed, 60 insertions(+) |
10 | 10 | ||
11 | diff --git a/hw/vfio/ap.c b/hw/vfio/ap.c | 11 | diff --git a/hw/vfio/ap.c b/hw/vfio/ap.c |
12 | index XXXXXXX..XXXXXXX 100644 | 12 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/hw/vfio/ap.c | 13 | --- a/hw/vfio/ap.c |
14 | +++ b/hw/vfio/ap.c | 14 | +++ b/hw/vfio/ap.c |
15 | @@ -XXX,XX +XXX,XX @@ static void vfio_ap_cfg_chg_notifier_handler(void *opaque) | 15 | @@ -XXX,XX +XXX,XX @@ static void vfio_ap_cfg_chg_notifier_handler(void *opaque) |
16 | css_generate_css_crws(0); | 16 | |
17 | } | 17 | } |
18 | 18 | ||
19 | +int ap_chsc_sei_nt0_get_event(void *res) | 19 | +int ap_chsc_sei_nt0_get_event(void *res) |
20 | +{ | 20 | +{ |
21 | + APConfigChgEvent *cfg_chg_event = QTAILQ_FIRST(&cfg_chg_events); | 21 | + APConfigChgEvent *cfg_chg_event = QTAILQ_FIRST(&cfg_chg_events); |
22 | + ChscSeiNt0Res *nt0_res = (ChscSeiNt0Res *)res; | 22 | + ChscSeiNt0Res *nt0_res = (ChscSeiNt0Res *)res; |
23 | + | ||
23 | + memset(nt0_res, 0, sizeof(*nt0_res)); | 24 | + memset(nt0_res, 0, sizeof(*nt0_res)); |
24 | + int rc = 1; | ||
25 | + | 25 | + |
26 | + if (cfg_chg_event) { | 26 | + if (!cfg_chg_event) { |
27 | + QTAILQ_REMOVE(&cfg_chg_events, cfg_chg_event, next); | 27 | + return 1; |
28 | + free(cfg_chg_event); | ||
29 | + | ||
30 | + /* | ||
31 | + * If there are any AP configuration change events in the queue, | ||
32 | + * indicate to the caller that there is pending event info in | ||
33 | + * the response block | ||
34 | + */ | ||
35 | + if (!QTAILQ_EMPTY(&cfg_chg_events)) { | ||
36 | + nt0_res->flags |= PENDING_EVENT_INFO_BITMASK; | ||
37 | + } | ||
38 | + | ||
39 | + nt0_res->length = sizeof(ChscSeiNt0Res); | ||
40 | + nt0_res->code = 1; | ||
41 | + nt0_res->nt = 0; | ||
42 | + nt0_res->rs = 5; | ||
43 | + nt0_res->cc = 3; | ||
44 | + | ||
45 | + rc = 0; | ||
46 | + } | 28 | + } |
47 | + | 29 | + |
48 | + return rc; | 30 | + QTAILQ_REMOVE(&cfg_chg_events, cfg_chg_event, next); |
31 | + g_free(cfg_chg_event); | ||
32 | + | ||
33 | + /* | ||
34 | + * If there are any AP configuration change events in the queue, | ||
35 | + * indicate to the caller that there is pending event info in | ||
36 | + * the response block | ||
37 | + */ | ||
38 | + if (ap_chsc_sei_nt0_have_event()) { | ||
39 | + nt0_res->flags |= PENDING_EVENT_INFO_BITMASK; | ||
40 | + } | ||
41 | + | ||
42 | + nt0_res->length = sizeof(ChscSeiNt0Res); | ||
43 | + nt0_res->code = NT0_RES_RESPONSE_CODE; | ||
44 | + nt0_res->nt = NT0_RES_NT_DEFAULT; | ||
45 | + nt0_res->rs = NT0_RES_RS_AP_CHANGE; | ||
46 | + nt0_res->cc = NT0_RES_CC_AP_CHANGE; | ||
47 | + | ||
48 | + return 0; | ||
49 | + | ||
49 | +} | 50 | +} |
50 | + | 51 | + |
51 | +int ap_chsc_sei_nt0_have_event(void) | 52 | +int ap_chsc_sei_nt0_have_event(void) |
52 | +{ | 53 | +{ |
53 | + return !QTAILQ_EMPTY(&cfg_chg_events); | 54 | + return !QTAILQ_EMPTY(&cfg_chg_events); |
... | ... | ||
75 | + uint8_t reserved3; | 76 | + uint8_t reserved3; |
76 | + uint8_t rs; | 77 | + uint8_t rs; |
77 | + uint8_t cc; | 78 | + uint8_t cc; |
78 | +} QEMU_PACKED ChscSeiNt0Res; | 79 | +} QEMU_PACKED ChscSeiNt0Res; |
79 | + | 80 | + |
81 | +#define NT0_RES_RESPONSE_CODE 1; | ||
82 | +#define NT0_RES_NT_DEFAULT 0; | ||
83 | +#define NT0_RES_RS_AP_CHANGE 5; | ||
84 | +#define NT0_RES_CC_AP_CHANGE 3; | ||
85 | + | ||
80 | +int ap_chsc_sei_nt0_get_event(void *res); | 86 | +int ap_chsc_sei_nt0_get_event(void *res); |
81 | + | 87 | + |
82 | +int ap_chsc_sei_nt0_have_event(void); | 88 | +int ap_chsc_sei_nt0_have_event(void); |
83 | + | 89 | + |
84 | #endif | 90 | #endif |
85 | -- | 91 | -- |
86 | 2.39.5 (Apple Git-154) | 92 | 2.48.1 | diff view generated by jsdifflib |
... | ... | ||
---|---|---|---|
41 | + | 41 | + |
42 | return 0; | 42 | return 0; |
43 | } | 43 | } |
44 | 44 | ||
45 | -- | 45 | -- |
46 | 2.39.5 (Apple Git-154) | 46 | 2.48.1 | diff view generated by jsdifflib |