s390/ipl: sync back loadparm
PATCH 1/1 s390/ipl: sync back loadparm
We expose loadparm as a r/w machine property, but if loadparm is set by the guest via DIAG 308, we don't update the property. Having a disconnect between the guest view and the QEMU property is not nice in itself, but things get even worse for SCSI, where under certain circumstances (see 789b5a401b "s390: Ensure IPL from SCSI works as expected" for details) we call s390_gen_initial_iplb() on resets effectively overwriting the guest/user supplied loadparm with the stale value.
--- hw/s390x/ipl.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)
hw/s390x/ipl.c +21 -0
@@ -538,6 +538,26 @@ static bool is_virtio_scsi_device(IplParameterBlock *iplb)return is_virtio_ccw_device_of_type (iplb,VIRTIO_ID_SCSI ); } +static void update_machine_ipl_properties (IplParameterBlock *iplb) +{ +Object *mo =qdev_get_machine (); + +/* Sync loadparm */ +if (iplb->flags &DIAG308_FLAGS_LP_VALID ) { +char ascii_loadparm[8 ]; +uint8_t *ebcdic_loadparm = iplb->loadparm; +int i; + +for (i =0 ; i <8 && ebcdic_loadparm[i]; i++) { + ascii_loadparm[i] = ebcdic2ascii[(uint8_t ) ebcdic_loadparm[i]]; + } + ascii_loadparm[i] =0 ; +object_property_set_str (mo, ascii_loadparm,"loadparm" ,NULL ); + }else { +object_property_set_str (mo,"" ,"loadparm" ,NULL ); + } +} +void s390_ipl_update_diag308 (IplParameterBlock *iplb) {S390IPLState *ipl =get_ipl_device ();
@@ -545,6 +565,7 @@ void s390_ipl_update_diag308(IplParameterBlock *iplb) ipl->iplb = *iplb; ipl->iplb_valid = true; ipl->netboot =is_virtio_net_device (iplb); +update_machine_ipl_properties (iplb); }IplParameterBlock *s390_ipl_get_iplb (void )
base-commit: c1e667d2598b9b3ce62b8e89ed22dd38dfe9f57f
Signature · 1 line
2.17.1
Quoted 24 lines · Halil Pasic
We expose loadparm as a r/w machine property, but if loadparm is set by the guest via DIAG 308, we don't update the property. Having a disconnect between the guest view and the QEMU property is not nice in itself, but things get even worse for SCSI, where under certain circumstances (see
789b5a401b"s390: Ensure IPL from SCSI works as expected" for details) we calls390_gen_initial_iplb()on resets effectively overwriting the guest/user supplied loadparm with the stale value.Signed-off-by Halil Pasic <[email protected]>Fixes 7104bae9de "hw/s390x: provide loadparm property for the machine"Reported-by Marc Hartmayer <[email protected]>Reviewed-by Janosch Frank <[email protected]>Reviewed-by Viktor Mihajlovski <[email protected]>Tested-by Marc Hartmayer <[email protected]>--- hw/s390x/ipl.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)hw/s390x/ipl.c +0
-0
hw/s390x/ipl.c static bool is_virtio_scsi_device(IplParameterBlock *iplb) · line 543
Quoted 6 lines
hw/s390x/ipl.c +3
-0@@ -538,6 +538,26 @@ static bool is_virtio_scsi_device(IplParameterBlock *iplb)return is_virtio_ccw_device_of_type (iplb,VIRTIO_ID_SCSI ); } +static void update_machine_ipl_properties (IplParameterBlock *iplb) +{ +Object *mo =qdev_get_machine ();
I'd just call this "machine".
Quoted 5 lines
hw/s390x/ipl.c +5
-0+ +/* Sync loadparm */ +if (iplb->flags &DIAG308_FLAGS_LP_VALID ) { +char ascii_loadparm[8 ]; +uint8_t *ebcdic_loadparm = iplb->loadparm;
hw/s390x/ipl.c static bool is_virtio_scsi_device(IplParameterBlock *iplb) · line 558
Quoted 10 lines
hw/s390x/ipl.c +10
-0+int i; + +for (i =0 ; i <8 && ebcdic_loadparm[i]; i++) { + ascii_loadparm[i] = ebcdic2ascii[(uint8_t ) ebcdic_loadparm[i]]; + } + ascii_loadparm[i] =0 ; +object_property_set_str (mo, ascii_loadparm,"loadparm" ,NULL ); + }else { +object_property_set_str (mo,"" ,"loadparm" ,NULL ); + }
&error_abort instead of NULL, we certainly want to know if this would ever surprisingly fail.
hw/s390x/ipl.c void s390_ipl_update_diag308(IplParameterBlock *iplb) · line 570
Quoted 12 lines
hw/s390x/ipl.c +3
-0+} +void s390_ipl_update_diag308 (IplParameterBlock *iplb) {S390IPLState *ipl =get_ipl_device ();@@ -545,6 +565,7 @@ void s390_ipl_update_diag308(IplParameterBlock *iplb) ipl->iplb = *iplb; ipl->iplb_valid = true; ipl->netboot =is_virtio_net_device (iplb); +update_machine_ipl_properties (iplb); }
Somewhat I dislike this manual syncing (and converting back and forth), but there seems to be no easy way around it.
Signature · 3 lines
Thanks, David / dhildenb
Quoted 28 lines · On Tue, 25 Feb 2020 10:39:40 +0100 David Hildenbrand <[email protected]> wrote:
Quoted 27 lines · Halil Pasic
We expose loadparm as a r/w machine property, but if loadparm is set by the guest via DIAG 308, we don't update the property. Having a disconnect between the guest view and the QEMU property is not nice in itself, but things get even worse for SCSI, where under certain circumstances (see
789b5a401b"s390: Ensure IPL from SCSI works as expected" for details) we calls390_gen_initial_iplb()on resets effectively overwriting the guest/user supplied loadparm with the stale value.Signed-off-by Halil Pasic <[email protected]>Fixes 7104bae9de "hw/s390x: provide loadparm property for the machine"Reported-by Marc Hartmayer <[email protected]>Reviewed-by Janosch Frank <[email protected]>Reviewed-by Viktor Mihajlovski <[email protected]>Tested-by Marc Hartmayer <[email protected]>--- hw/s390x/ipl.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)hw/s390x/ipl.c +0
-0@@ -538,6 +538,26 @@ static bool is_virtio_scsi_device(IplParameterBlock *iplb)return is_virtio_ccw_device_of_type (iplb,VIRTIO_ID_SCSI ); }
Quoted 6 lines
hw/s390x/ipl.c static bool is_virtio_scsi_device(IplParameterBlock *iplb) · line 543
Quoted 3 lines
hw/s390x/ipl.c +3
-0+static void update_machine_ipl_properties (IplParameterBlock *iplb) +{ +Object *mo =qdev_get_machine ();I'd just call this "machine".
I can change that.
Quoted 10 lines
Quoted 10 lines
hw/s390x/ipl.c +10
-0+ +/* Sync loadparm */ +if (iplb->flags &DIAG308_FLAGS_LP_VALID ) { +char ascii_loadparm[8 ]; +uint8_t *ebcdic_loadparm = iplb->loadparm; +int i; + +for (i =0 ; i <8 && ebcdic_loadparm[i]; i++) { + ascii_loadparm[i] = ebcdic2ascii[(uint8_t ) ebcdic_loadparm[i]]; + }
Quoted 8 lines
hw/s390x/ipl.c static bool is_virtio_scsi_device(IplParameterBlock *iplb) · line 558
Quoted 5 lines
hw/s390x/ipl.c +5
-0+ ascii_loadparm[i] =0 ; +object_property_set_str (mo, ascii_loadparm,"loadparm" ,NULL ); + }else { +object_property_set_str (mo,"" ,"loadparm" ,NULL ); + }
&error_abortinstead of NULL, we certainly want to know if this would ever surprisingly fail.
IMHO this is a typical assert() situation where one would like to have a fast and obvious failure when testing, but not in production.
AFAIU the guest can trigger this code at any time, and crashing the whole (production) system seems a bit heavy handed to me. The setter should only fail if something is buggy.
But if the majority says &error_abort I can certainly do. Other opinions?
Quoted 17 lines
hw/s390x/ipl.c void s390_ipl_update_diag308(IplParameterBlock *iplb) · line 570
Quoted 13 lines
hw/s390x/ipl.c +3
-0+} +void s390_ipl_update_diag308 (IplParameterBlock *iplb) {S390IPLState *ipl =get_ipl_device ();@@ -545,6 +565,7 @@ void s390_ipl_update_diag308(IplParameterBlock *iplb) ipl->iplb = *iplb; ipl->iplb_valid = true; ipl->netboot =is_virtio_net_device (iplb); +update_machine_ipl_properties (iplb); }Somewhat I dislike this manual syncing (and converting back and forth), but there seems to be no easy way around it.
I share your sentiment.
Regards,
Halil
Quoted 24 lines · Halil Pasic
Quoted 21 lines · On Tue, 25 Feb 2020 10:39:40 +0100 David Hildenbrand <[email protected]> wrote:
Quoted 20 lines · Halil Pasic
We expose loadparm as a r/w machine property, but if loadparm is set by the guest via DIAG 308, we don't update the property. Having a disconnect between the guest view and the QEMU property is not nice in itself, but things get even worse for SCSI, where under certain circumstances (see
789b5a401b"s390: Ensure IPL from SCSI works as expected" for details) we calls390_gen_initial_iplb()on resets effectively overwriting the guest/user supplied loadparm with the stale value.Signed-off-by Halil Pasic <[email protected]>Fixes 7104bae9de "hw/s390x: provide loadparm property for the machine"Reported-by Marc Hartmayer <[email protected]>Reviewed-by Janosch Frank <[email protected]>Reviewed-by Viktor Mihajlovski <[email protected]>Tested-by Marc Hartmayer <[email protected]>--- hw/s390x/ipl.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)hw/s390x/ipl.c +0
-0
[...]
Quoted 19 lines
Quoted 10 lines
Quoted 10 lines
hw/s390x/ipl.c +10
-0+ +/* Sync loadparm */ +if (iplb->flags &DIAG308_FLAGS_LP_VALID ) { +char ascii_loadparm[8 ]; +uint8_t *ebcdic_loadparm = iplb->loadparm; +int i; + +for (i =0 ; i <8 && ebcdic_loadparm[i]; i++) { + ascii_loadparm[i] = ebcdic2ascii[(uint8_t ) ebcdic_loadparm[i]]; + }Quoted 8 lines
hw/s390x/ipl.c static bool is_virtio_scsi_device(IplParameterBlock *iplb) · line 558
Quoted 5 lines
hw/s390x/ipl.c +5
-0+ ascii_loadparm[i] =0 ; +object_property_set_str (mo, ascii_loadparm,"loadparm" ,NULL ); + }else { +object_property_set_str (mo,"" ,"loadparm" ,NULL ); + }
&error_abortinstead of NULL, we certainly want to know if this would ever surprisingly fail.
Quoted 9 lines
IMHO this is a typical
assert()situation where one would like to have a fast and obvious failure when testing, but not in production.AFAIU the guest can trigger this code at any time, and crashing the whole (production) system seems a bit heavy handed to me. The setter should only fail if something is buggy.
But if the majority says
&error_abortI can certainly do. Other opinions?
We might consider to return 0x0402 (invalid parameter) from the diag308 "set", which is less drastic and would allow the OS to do whatever it finds appropriate to deal with the failure. Not that Linux would care about that today :-).
[...]
Signature · 2 lines
Kind Regards, Viktor
Quoted 14 lines · On Tue, 25 Feb 2020 15:35:47 +0100 Viktor Mihajlovski <[email protected]>…
Quoted 13 lines · Halil Pasic
Quoted 10 lines · On Tue, 25 Feb 2020 10:39:40 +0100 David Hildenbrand <[email protected]> wrote:
Quoted 9 lines · Halil Pasic
We expose loadparm as a r/w machine property, but if loadparm is set by the guest via DIAG 308, we don't update the property. Having a disconnect between the guest view and the QEMU property is not nice in itself, but things get even worse for SCSI, where under certain circumstances (see
789b5a401b"s390: Ensure IPL from SCSI works as expected" for details) we calls390_gen_initial_iplb()on resets effectively overwriting the guest/user supplied loadparm with the stale value.
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Signed-off-by Halil Pasic <[email protected]>Fixes 7104bae9de "hw/s390x: provide loadparm property for the machine"
Please use the format
Quoted 36 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Reported-by Marc Hartmayer <[email protected]>Reviewed-by Janosch Frank <[email protected]>Reviewed-by Viktor Mihajlovski <[email protected]>Tested-by Marc Hartmayer <[email protected]>--- hw/s390x/ipl.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)hw/s390x/ipl.c +0
-0[...]
Quoted 26 lines
Quoted 10 lines
Quoted 10 lines
hw/s390x/ipl.c +10
-0+ +/* Sync loadparm */ +if (iplb->flags &DIAG308_FLAGS_LP_VALID ) { +char ascii_loadparm[8 ]; +uint8_t *ebcdic_loadparm = iplb->loadparm; +int i; + +for (i =0 ; i <8 && ebcdic_loadparm[i]; i++) { + ascii_loadparm[i] = ebcdic2ascii[(uint8_t ) ebcdic_loadparm[i]]; + }Quoted 8 lines
hw/s390x/ipl.c static bool is_virtio_scsi_device(IplParameterBlock *iplb) · line 558
Quoted 5 lines
hw/s390x/ipl.c +5
-0+ ascii_loadparm[i] =0 ; +object_property_set_str (mo, ascii_loadparm,"loadparm" ,NULL ); + }else { +object_property_set_str (mo,"" ,"loadparm" ,NULL ); + }
&error_abortinstead of NULL, we certainly want to know if this would ever surprisingly fail.IMHO this is a typical
assert()situation where one would like to have a fast and obvious failure when testing, but not in production.AFAIU the guest can trigger this code at any time, and crashing the whole (production) system seems a bit heavy handed to me. The setter should only fail if something is buggy.
Quoted 6 lines
Quoted 2 lines
But if the majority says
&error_abortI can certainly do. Other opinions?We might consider to return
0x0402(invalid parameter) from the diag308 "set", which is less drastic and would allow the OS to do whatever it finds appropriate to deal with the failure. Not that Linux would care about that today :-).
I'm not sure if we could actually get there in any other way than via a QEMU coding error... not sure if I would trust QEMU to inject a return code if it already had a code logic fail right before that :)
Quoted 50 lines · Viktor Mihajlovski
Quoted 24 lines · Halil Pasic
Quoted 21 lines · On Tue, 25 Feb 2020 10:39:40 +0100 David Hildenbrand <[email protected]> wrote:
Quoted 20 lines · Halil Pasic
We expose loadparm as a r/w machine property, but if loadparm is set by the guest via DIAG 308, we don't update the property. Having a disconnect between the guest view and the QEMU property is not nice in itself, but things get even worse for SCSI, where under certain circumstances (see
789b5a401b"s390: Ensure IPL from SCSI works as expected" for details) we calls390_gen_initial_iplb()on resets effectively overwriting the guest/user supplied loadparm with the stale value.Signed-off-by Halil Pasic <[email protected]>Fixes 7104bae9de "hw/s390x: provide loadparm property for the machine"Reported-by Marc Hartmayer <[email protected]>Reviewed-by Janosch Frank <[email protected]>Reviewed-by Viktor Mihajlovski <[email protected]>Tested-by Marc Hartmayer <[email protected]>---
hw/s390x/ipl.c| 21 +++++++++++++++++++++1 file changed, 21 insertions(+)hw/s390x/ipl.c +0
-0[...]
Quoted 22 lines
Quoted 10 lines
Quoted 10 lines
hw/s390x/ipl.c +10
-0+ + /* Sync loadparm */ + if (iplb->flags & DIAG308_FLAGS_LP_VALID) { + char ascii_loadparm[8]; + uint8_t *ebcdic_loadparm = iplb->loadparm; + int i; + + for (i = 0; i < 8 && ebcdic_loadparm[i]; i++) { + ascii_loadparm[i] = ebcdic2ascii[(uint8_t) ebcdic_loadparm[i]]; + }Quoted 8 lines
Quoted 5 lines
+ ascii_loadparm[i] = 0;
+object_property_set_str(mo, ascii_loadparm, "loadparm", NULL); + } else {
+object_property_set_str(mo, "", "loadparm", NULL); + }
&error_abortinstead of NULL, we certainly want to know if this would ever surprisingly fail.IMHO this is a typical
assert()situation where one would like to have a fast and obvious failure when testing, but not in production.
Quoted 7 lines
Quoted 6 lines
AFAIU the guest can trigger this code at any time, and crashing the whole (production) system seems a bit heavy handed to me. The setter should only fail if something is buggy.
But if the majority says
&error_abortI can certainly do. Other opinions?We might consider to return
0x0402(invalid parameter) from the diag308 "set", which is less drastic and would allow the OS to do whatever it finds appropriate to deal with the failure. Not that Linux would care about that today :-).
I think it is not an error. It is perfectly fine for a guest to not set DIAG308_FLAGS_LP_VALID if the guest does not want to set it. The LOADPARM is supposed to be ignored then.
So we have two options:
a. leave the patch as-is. This means that we replace the loadparm with an empty string
b. remove the else. THis means that we leave the global loadparm unchanged if the guest does not specify one (but it specifies a new IPLB).
I will double check what LPAR does.
Quoted 57 lines · On Thu, 5 Mar 2020 13:44:31 +0100 Christian Borntraeger…
Quoted 54 lines · Viktor Mihajlovski
Quoted 24 lines · Halil Pasic
Quoted 21 lines · On Tue, 25 Feb 2020 10:39:40 +0100 David Hildenbrand <[email protected]> wrote:
Quoted 20 lines · Halil Pasic
We expose loadparm as a r/w machine property, but if loadparm is set by the guest via DIAG 308, we don't update the property. Having a disconnect between the guest view and the QEMU property is not nice in itself, but things get even worse for SCSI, where under certain circumstances (see
789b5a401b"s390: Ensure IPL from SCSI works as expected" for details) we calls390_gen_initial_iplb()on resets effectively overwriting the guest/user supplied loadparm with the stale value.Signed-off-by Halil Pasic <[email protected]>Fixes 7104bae9de "hw/s390x: provide loadparm property for the machine"Reported-by Marc Hartmayer <[email protected]>Reviewed-by Janosch Frank <[email protected]>Reviewed-by Viktor Mihajlovski <[email protected]>Tested-by Marc Hartmayer <[email protected]>---
hw/s390x/ipl.c| 21 +++++++++++++++++++++1 file changed, 21 insertions(+)hw/s390x/ipl.c +0
-0[...]
Quoted 26 lines
Quoted 10 lines
Quoted 10 lines
hw/s390x/ipl.c +10
-0+ + /* Sync loadparm */ + if (iplb->flags & DIAG308_FLAGS_LP_VALID) { + char ascii_loadparm[8]; + uint8_t *ebcdic_loadparm = iplb->loadparm; + int i; + + for (i = 0; i < 8 && ebcdic_loadparm[i]; i++) { + ascii_loadparm[i] = ebcdic2ascii[(uint8_t) ebcdic_loadparm[i]]; + }Quoted 8 lines
Quoted 5 lines
+ ascii_loadparm[i] = 0;
+object_property_set_str(mo, ascii_loadparm, "loadparm", NULL); + } else {
+object_property_set_str(mo, "", "loadparm", NULL); + }
&error_abortinstead of NULL, we certainly want to know if this would ever surprisingly fail.IMHO this is a typical
assert()situation where one would like to have a fast and obvious failure when testing, but not in production.AFAIU the guest can trigger this code at any time, and crashing the whole (production) system seems a bit heavy handed to me. The setter should only fail if something is buggy.
Quoted 6 lines
Quoted 3 lines
Quoted 2 lines
But if the majority says
&error_abortI can certainly do. Other opinions?We might consider to return
0x0402(invalid parameter) from the diag308 "set", which is less drastic and would allow the OS to do whatever it finds appropriate to deal with the failure. Not that Linux would care about that today :-).I think it is not an error. It is perfectly fine for a guest to not set
DIAG308_FLAGS_LP_VALIDif the guest does not want to set it. The LOADPARM is supposed to be ignored then.
I believe David's concern was not the else branch, but the last parameter of object_property_set_str(), which tells us what to do if the validation/normalization done by the setter of the loadparm qemu property fails the set operation.
Quoted 6 lines
So we have two options:
a. leave the patch as-is. This means that we replace the loadparm with an empty string
b. remove the else. THis means that we leave the global loadparm unchanged if the guest does not specify one (but it specifies a new IPLB).I will double check what LPAR does.
Thanks! BTW my reading of the architecture and understanding how we expose it via qemu interfaces makes me to lean towards option a). In my understanding we represent invalid loadparm with an empty string in the context of the qemu property. That is we don't expose the garbage-value.
Regards,
Halil
Quoted 64 lines · Halil Pasic
Quoted 61 lines · On Thu, 5 Mar 2020 13:44:31 +0100 Christian Borntraeger…
Quoted 57 lines · Viktor Mihajlovski
Quoted 24 lines · Halil Pasic
Quoted 21 lines · On Tue, 25 Feb 2020 10:39:40 +0100 David Hildenbrand <[email protected]> wrote:
Quoted 20 lines · Halil Pasic
We expose loadparm as a r/w machine property, but if loadparm is set by the guest via DIAG 308, we don't update the property. Having a disconnect between the guest view and the QEMU property is not nice in itself, but things get even worse for SCSI, where under certain circumstances (see
789b5a401b"s390: Ensure IPL from SCSI works as expected" for details) we calls390_gen_initial_iplb()on resets effectively overwriting the guest/user supplied loadparm with the stale value.Signed-off-by Halil Pasic <[email protected]>Fixes 7104bae9de "hw/s390x: provide loadparm property for the machine"Reported-by Marc Hartmayer <[email protected]>Reviewed-by Janosch Frank <[email protected]>Reviewed-by Viktor Mihajlovski <[email protected]>Tested-by Marc Hartmayer <[email protected]>---
hw/s390x/ipl.c| 21 +++++++++++++++++++++1 file changed, 21 insertions(+)hw/s390x/ipl.c +0
-0[...]
Quoted 19 lines
Quoted 10 lines
Quoted 10 lines
hw/s390x/ipl.c +10
-0+ + /* Sync loadparm */ + if (iplb->flags & DIAG308_FLAGS_LP_VALID) { + char ascii_loadparm[8]; + uint8_t *ebcdic_loadparm = iplb->loadparm; + int i; + + for (i = 0; i < 8 && ebcdic_loadparm[i]; i++) { + ascii_loadparm[i] = ebcdic2ascii[(uint8_t) ebcdic_loadparm[i]]; + }Quoted 8 lines
Quoted 5 lines
+ ascii_loadparm[i] = 0;
+object_property_set_str(mo, ascii_loadparm, "loadparm", NULL); + } else {
+object_property_set_str(mo, "", "loadparm", NULL); + }
&error_abortinstead of NULL, we certainly want to know if this would ever surprisingly fail.Quoted 9 lines
IMHO this is a typical
assert()situation where one would like to have a fast and obvious failure when testing, but not in production.AFAIU the guest can trigger this code at any time, and crashing the whole (production) system seems a bit heavy handed to me. The setter should only fail if something is buggy.
But if the majority says
&error_abortI can certainly do. Other opinions?We might consider to return
0x0402(invalid parameter) from the diag308 "set", which is less drastic and would allow the OS to do whatever it finds appropriate to deal with the failure. Not that Linux would care about that today :-).
Quoted 7 lines
Quoted 2 lines
I think it is not an error. It is perfectly fine for a guest to not set
DIAG308_FLAGS_LP_VALIDif the guest does not want to set it. The LOADPARM is supposed to be ignored then.I believe David's concern was not the else branch, but the last parameter of
object_property_set_str(), which tells us what to do if the validation/normalization done by the setter of the loadparm qemu property fails the set operation.
Ah I see. I still think that the guest could provoke the an error by putting invalid characters in the loadparm field. So error_abort seems wrong. And in fact for that case, the 0x0402 proposal from Viktor seems like the right thing to do.
Quoted 75 lines · Christian Borntraeger
Quoted 64 lines · Halil Pasic
Quoted 61 lines · On Thu, 5 Mar 2020 13:44:31 +0100 Christian Borntraeger…
Quoted 57 lines · Viktor Mihajlovski
Quoted 24 lines · Halil Pasic
Quoted 21 lines · On Tue, 25 Feb 2020 10:39:40 +0100 David Hildenbrand <[email protected]> wrote:
Quoted 20 lines · Halil Pasic
We expose loadparm as a r/w machine property, but if loadparm is set by the guest via DIAG 308, we don't update the property. Having a disconnect between the guest view and the QEMU property is not nice in itself, but things get even worse for SCSI, where under certain circumstances (see
789b5a401b"s390: Ensure IPL from SCSI works as expected" for details) we calls390_gen_initial_iplb()on resets effectively overwriting the guest/user supplied loadparm with the stale value.Signed-off-by Halil Pasic <[email protected]>Fixes 7104bae9de "hw/s390x: provide loadparm property for the machine"Reported-by Marc Hartmayer <[email protected]>Reviewed-by Janosch Frank <[email protected]>Reviewed-by Viktor Mihajlovski <[email protected]>Tested-by Marc Hartmayer <[email protected]>---
hw/s390x/ipl.c| 21 +++++++++++++++++++++1 file changed, 21 insertions(+)hw/s390x/ipl.c +0
-0[...]
Quoted 19 lines
Quoted 10 lines
Quoted 10 lines
hw/s390x/ipl.c +10
-0+ + /* Sync loadparm */ + if (iplb->flags & DIAG308_FLAGS_LP_VALID) { + char ascii_loadparm[8]; + uint8_t *ebcdic_loadparm = iplb->loadparm; + int i; + + for (i = 0; i < 8 && ebcdic_loadparm[i]; i++) { + ascii_loadparm[i] = ebcdic2ascii[(uint8_t) ebcdic_loadparm[i]]; + }Quoted 8 lines
Quoted 5 lines
+ ascii_loadparm[i] = 0;
+object_property_set_str(mo, ascii_loadparm, "loadparm", NULL); + } else {
+object_property_set_str(mo, "", "loadparm", NULL); + }
&error_abortinstead of NULL, we certainly want to know if this would ever surprisingly fail.Quoted 9 lines
IMHO this is a typical
assert()situation where one would like to have a fast and obvious failure when testing, but not in production.AFAIU the guest can trigger this code at any time, and crashing the whole (production) system seems a bit heavy handed to me. The setter should only fail if something is buggy.
But if the majority says
&error_abortI can certainly do. Other opinions?We might consider to return
0x0402(invalid parameter) from the diag308 "set", which is less drastic and would allow the OS to do whatever it finds appropriate to deal with the failure. Not that Linux would care about that today :-).Quoted 7 lines
Quoted 2 lines
I think it is not an error. It is perfectly fine for a guest to not set
DIAG308_FLAGS_LP_VALIDif the guest does not want to set it. The LOADPARM is supposed to be ignored then.I believe David's concern was not the else branch, but the last parameter of
object_property_set_str(), which tells us what to do if the validation/normalization done by the setter of the loadparm qemu property fails the set operation.
Quoted 4 lines
Ah I see. I still think that the guest could provoke the an error by putting invalid characters in the loadparm field. So
error_abortseems wrong. And in fact for that case, the0x0402proposal from Viktor seems like the right thing to do.
FWIW, right now we do not check the content of the loadparm and just accept any kind of garbage via diag308 and we return that garbage.
And I checked what LPAR does. LPAR also does not use 0x0402 and it silently takes the garbage.
So in essence I would suggest to leave the patch as is.
Quoted 83 lines · On Thu, 5 Mar 2020 17:21:44 +0100 Christian Borntraeger…
Quoted 75 lines · Christian Borntraeger
Quoted 64 lines · Halil Pasic
Quoted 61 lines · On Thu, 5 Mar 2020 13:44:31 +0100 Christian Borntraeger…
Quoted 57 lines · Viktor Mihajlovski
Quoted 24 lines · Halil Pasic
Quoted 21 lines · On Tue, 25 Feb 2020 10:39:40 +0100 David Hildenbrand <[email protected]> wrote:
Quoted 20 lines · Halil Pasic
We expose loadparm as a r/w machine property, but if loadparm is set by the guest via DIAG 308, we don't update the property. Having a disconnect between the guest view and the QEMU property is not nice in itself, but things get even worse for SCSI, where under certain circumstances (see
789b5a401b"s390: Ensure IPL from SCSI works as expected" for details) we calls390_gen_initial_iplb()on resets effectively overwriting the guest/user supplied loadparm with the stale value.Signed-off-by Halil Pasic <[email protected]>Fixes 7104bae9de "hw/s390x: provide loadparm property for the machine"Reported-by Marc Hartmayer <[email protected]>Reviewed-by Janosch Frank <[email protected]>Reviewed-by Viktor Mihajlovski <[email protected]>Tested-by Marc Hartmayer <[email protected]>---
hw/s390x/ipl.c| 21 +++++++++++++++++++++1 file changed, 21 insertions(+)hw/s390x/ipl.c +0
-0[...]
Quoted 19 lines
Quoted 10 lines
Quoted 10 lines
hw/s390x/ipl.c +10
-0+ + /* Sync loadparm */ + if (iplb->flags & DIAG308_FLAGS_LP_VALID) { + char ascii_loadparm[8]; + uint8_t *ebcdic_loadparm = iplb->loadparm; + int i; + + for (i = 0; i < 8 && ebcdic_loadparm[i]; i++) { + ascii_loadparm[i] = ebcdic2ascii[(uint8_t) ebcdic_loadparm[i]]; + }Quoted 8 lines
Quoted 5 lines
+ ascii_loadparm[i] = 0;
+object_property_set_str(mo, ascii_loadparm, "loadparm", NULL); + } else {
+object_property_set_str(mo, "", "loadparm", NULL); + }
&error_abortinstead of NULL, we certainly want to know if this would ever surprisingly fail.Quoted 9 lines
IMHO this is a typical
assert()situation where one would like to have a fast and obvious failure when testing, but not in production.AFAIU the guest can trigger this code at any time, and crashing the whole (production) system seems a bit heavy handed to me. The setter should only fail if something is buggy.
But if the majority says
&error_abortI can certainly do. Other opinions?We might consider to return
0x0402(invalid parameter) from the diag308 "set", which is less drastic and would allow the OS to do whatever it finds appropriate to deal with the failure. Not that Linux would care about that today :-).Quoted 7 lines
Quoted 2 lines
I think it is not an error. It is perfectly fine for a guest to not set
DIAG308_FLAGS_LP_VALIDif the guest does not want to set it. The LOADPARM is supposed to be ignored then.I believe David's concern was not the else branch, but the last parameter of
object_property_set_str(), which tells us what to do if the validation/normalization done by the setter of the loadparm qemu property fails the set operation.Quoted 4 lines
Ah I see. I still think that the guest could provoke the an error by putting invalid characters in the loadparm field. So
error_abortseems wrong. And in fact for that case, the0x0402proposal from Viktor seems like the right thing to do.
Quoted 6 lines
FWIW, right now we do not check the content of the loadparm and just accept any kind of garbage via diag308 and we return that garbage.
And I checked what LPAR does. LPAR also does not use0x0402and it silently takes the garbage.
So in essence I would suggest to leave the patch as is.
Ageed. I will do the cosmetics and send out the v2.
Regarding validation, I don't know where the criteria Farhan implemented come from. In the longer run we may want to do away with the validation and normalization performed in the setter, but for now I think this is pretty close to the sanest cheap fix we can do.
Regards,
Hali